vb.net compile error 'abc' is ambiguous in the namespace 'xyz'

后端 未结 4 1774
没有蜡笔的小新
没有蜡笔的小新 2021-01-18 23:28

I have a VB.Net solution that another developer created and I\'m trying to compile it on our build machine (it compiles on their machine) but with one of the projects I get

相关标签:
4条回答
  • 2021-01-18 23:50

    Check your references if you have two versions of the same reference (eg. Microsoft.ReportViewer.Webforms version 10.0.0.0 and Microsoft.ReportViewer.Webforms 8.0.0.0) You will get this error. Delete the oldest and you should be good. I do this to myself all of the time.

    0 讨论(0)
  • 2021-01-18 23:53

    I was facing same issue. I upgraded my application from vb6 to vb.net and when i change the build configuration from DEBUG to RELEASE then i got AMBIGUOUS errors. I found dulicate references folder in solution Explorer. I removed those duplicate referecnces and Build sucessfully. I Hope it may help others.

    0 讨论(0)
  • 2021-01-19 00:00

    Thanks for the responses! I tried each but still was having issues.

    One point of info I left out of the original question was that the VB.net projects are upgrades from VB6 projects. At the time I did not think that was relevant.

    After investigating further the build machine was used to build the VB6 projects also. So I ran 'reg32 /u' on the vb6 dlls and that seemed to fix the VB.net issue.

    Not exactly sure why this fixed it since I was not referencing the VB6 dlls, I'm guessing something to do with ambiguous entries in the registry confusing the vb.net project.

    0 讨论(0)
  • 2021-01-19 00:16

    There can be a few causes for this error. In VB, you should be aware that more names then you're used to from C# are available without class specification. Also, case does not matter in VB, which can further liken the chances on collisions.

    Even in the event that you don't find the actual conflicting issue, you can resolve this in the same way you would in C#: rename it in the Imports statement:

    Imports IM = yourAssembly.Imyinterface
    

    Then change the code such that uses of Imyinterface are replace with IM.

    NOTE: If the error does not point to a particular line, the conflict may be out of your hand. Normally, a full Clean Solution and Rebuild helps a lot, but occasionally a misbehaving file (i.e., another error) causes this error to popup first without clear source. Try to rollback recent changes to the place where it did work.

    You also say it worked on another machine. Chances are that your machine is having a different version of MS Visual Studio or .NET. Check and compare the exact versions.

    0 讨论(0)
提交回复
热议问题