views:

504

answers:

3

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 an error saying something along the lines of:

Imyinterface is ambiguous in the namespace anamespaceassembly.

I have tried with no success:

  • examined the references to see any obvious errors
  • removed and re-added the assembly in question
  • searched the system for the same dll
  • attempted to compile the original deve's src (.v the source control version)
  • examined the assembly with ildasm.exe

I usually code in C# and have not seen this error before (in this form at least), not that it is VB.Net specific but the UI for adding/viewing references is slightly different so I thought maybe VB.Net might do something different with references.

I also tried to compile on another machine, and it compiles ok. So I assume it is something with the build machine but I'm not sure what. Other conflicting assemblies somehow not referenced by the project, is that possible??

Any ideas?

A: 

Try to fully qualify the name pointed at by the error and re-compile. Does it work?

By the way, I am assuming you have checked the online help for the error message you are getting, right?

CesarGon
A: 

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.

Abel
A: 

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.

the empirical programmer