Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"An assembly with the same simple name has already been imported" error without duplicate reference

Tags:

I'm getting the following error:

error CS1704: An assembly with the same simple name 'Interop.xxx.dll, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null has already been imported. Try removing one of the references or sign them to enable side-by-side.

Everything I've seen says that I am referencing two assemblies with the same name and I need to remove one of them. However, I've checked and I'm only referencing it once.

This also only happens when I'm using msbuild to build from the command line on my dev box. If I build through Visual Studio or do a clean build on our CI server I don't see this error.

I've tried completely removing all of my source and building from scratch to more closely resemble the build machine but no luck.

like image 650
drs9222 Avatar asked Jul 01 '10 18:07

drs9222


2 Answers

So it looks like I can't read today!
The project had a reference to the Interop and a COM reference that generated the "same" interop. So there were two and I just didn't search very well. I still don't understand why it worked in other places but this did fix it.

like image 170
drs9222 Avatar answered Oct 20 '22 10:10

drs9222


In the Error List window, the project that was triggering this error was listed in the Project column. I got around the error by doing the following:

  • I unloaded the listed project (right-click => Unload Project)
  • Opened the XML for edit (right-click the unloaded project => Edit {ProjectName.csproj}).
  • Searched for the offending .dll, and noticed it was listed multiple times in the XML
  • Removed the entire Reference tag related to the offending dll, and did so for every copy of the reference except the first one listed

The reason it was listed multiple times was because several referenced libraries used that dll. This shouldn't be a problem, in and of itself, so I'm not sure what caused this error to suddenly pop up for me. I'll update this answer if I figure that out.

like image 28
BobbyA Avatar answered Oct 20 '22 09:10

BobbyA