Project References DLL version hell

霸气de小男生 提交于 2019-11-30 03:45:43

To avoid the dll hell I would recommend you to create a lib folder inside your project and put all shared assemblies in this folder. Next you Add References only from this folder. This way your project is self contained and you know exactly where it is picking the references from. If you want to update some assembly with a newer version you copy it to the lib folder and rebuild your project.

Also make sure you don't the referenced assemblies into the GAC as they might be picked up first.

There are few options that you can try.

  1. Compile the project and see in output window to verify the assembly path where it is referred from exactly.
  2. Delete Obj folder before you recompile it.
  3. Close and reopen the Visual Studio since VS has some weird behavior to keep the cache to hold Dll references.
  4. If you still see the problem, use this tool to check the reference assembly where it comes from really. Process Explorer.

To overcome this, I removed EVERY reference, then added them all back in again. I don't know why this is the solution.

It is possible that in one project a DLL was incorrect, and it is this incorrect DLL that was pulled through by visual studio and used.

Edit: Other times this error has occurred is due to a DDL (A) being referenced in the current project also being referenced by another DLL (B). Not rebuilding this other DLL (B) seems to prevent VS from referencing the correct version of DLL (A) in the current project and thus it brings through an older version of DLL (A).

Have you tried adding the reference as a Project Reference? i.e. Add Reference... -> Projects tab -> Select your project

We (and, as the only .NET developer on our team, by that I mean I) had the exact same problem. I traced it down to a referenced dll, which in turn AGAIN references the dll suffering from versionitis. It seems that because I wasn't updating all the references which in turn reference the dll, it was replaced by an older version at some point during the build process.

One of the symptoms I experienced was that when I am in the code editor, the new class I added to the referenced project would be coloured appropriately, but when I hit Build, it changes back to black and I get a message saying the class does not exist (along with a very sarcastic "Ar you missing an assembly reference?"). This led me to believe that the problem has to happen during the Build phase.

I would therefore suggest building any and every other project that points to this DLL and re-add their references too.

We are experiencing a very similar issue with the WPFToolkit. We just upgraded to the Feb 2010 release (using the March 5th msi). "Add References" shows the correct files in the correct location, but lists the old version #s. However, the physical files have the correct version #s. Have uninstalled, manually deleted any WPFToolkit references from the registry, etc., to no avail. It must be caching this stuff somewhere but we haven't been able to figure it out yet. Wasting hours on this.

Enable FusionLog and after the DLL fails to load, open the file with the DLL's name in the folder C:\FusionLog\Default\devenv.exe. This will show the path from where the DLL was really loaded.

In my case, an old version had mysteriously appeared in

C:\Program Files\Microsoft Visual Studio 10\Common7\IDE !

To stop this ever happening again, I added a security rule "Deny Write" to Everyone on Common7\IDE.

I had a problem similar to what is described here except that my solution to the problem had to do with how I was compiling the code. There is a difference between build, clean and Rebuild. In my case, I was just using a Build between my changes and the dll from the dependent solution were not being carried over with all the changes to the other solution where the reference was set. I solved it by using Rebuild which cleans, compiles and links all source files regardless of whether they changed or not. Then the dll from the the first solution was updated and copied over automatically to the 2nd solution where the reference was set and the problem was solved. Cheers, I hope this helps.

Toke Breer-Mortensen

Similar symptoms - problem was in "Referene paths" in Project Properties, Reference.

Full descrtiption and solution here: Referenced assemblies automatically replaced by visual studio visual-studio/22810867#22810867

Check Out this things:

  1. if problematic dll were referenced by both host web application and its referenced one. e.g. say, your web application uses abc.dll (problematic) and 1 other dll xyz.dll(i.e. class project which also reference abc.dll).

In this case, suppose, you've updated abc.dll from version 1 to version 2 and re-referenced in your web application. but during building process, the version 2 of abc.dll will change back to version 1, because, xyz.dll uses version 1 and web application overwrite abc.dll version 2 back to abc.dll version 1 during auto update on xyz.dll.

Solution: place updated version of abc.dll version 2 in class project bin of xyz.dll , too

Hope, above details will help, good luck

One possible reason is the Reference PATHs. If there's any reference to the old dll folder, VS will use it as the main reference, even though you added the new dll reference.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!