We're having problems getting visual studio to pick up the latest version of a DLL from one of our projects.
We have multiple class library projects (e.g. BusinessLogic, ReportData) and a number of web services, each has a reference to a Connectivity DLL we've written (this ref to the connectivity DLL is the problem).
We always point references to the DLL in the bin/debug folder, (which is where we always build to for any given project) and all custom DLL references have CopyLocal = True and SpecificVersion = False
ReportData has a reference to business logic (which also has a reference to connectivity - I don't see why this should cause a problem, but thought it is worth mentioning)
The weird thing is, when you click "Add Reference" and browse to Connectivity/bin/debug - you hover the mouse over the DLL file, the correct (latest) version is shown (version and file version are always incremented together), but when you click ok, a previous version number is pulled though. Even when I look in the current projects debug folder (where copy local would put the DLL after compiling) that shows the latest version number. - NO WHERE does can I find the previous version of the DLL outside of visual studio, but in that project references it has the old version - even though the path is correct.
I'm at a loss as to where it might be getting the old versions from. Or even why it wants that one.
This is possibly the most frustraighting problem I have ever come across.
Does anyone know how to ensure the latest version is pulled through (preferably automatically or on compile).
EDIT:
Although not exactly the scenario I'm dealing with I was reading this article and somewhere it mentions about CLR ignoring revision numbers. Understandable (even though this hasn't been a problem before - we're on revision 39), so I thought I would update the build number, still didn't work. In a vain attempt I though I would update the minor version number and see if that made any difference.
I'm not saying this is the answer as I have to check quite a few things first, but on the face of it, this seems to have solved my problem...
Further edit: In other class libraries this seems to have solved the problem, however in a test windows application it still pulls a previous version through :(
If I increment the minor version number again, the same problem come back and I am left with the wrong version being pulled though.
Further Edit - I created an entirly new project, added a reference and still had the exact same problem. This suggests the problem is restriced to the project I am referencing. Wish I knew why!
Anyone had this problem before and know how to get around it?
HELP!
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.
- Compile the project and see in output window to verify the assembly path where it is referred from exactly.
- Delete Obj folder before you recompile it.
- Close and reopen the Visual Studio since VS has some weird behavior to keep the cache to hold Dll references.
- 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.
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:
- 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.
来源:https://stackoverflow.com/questions/2357476/project-references-dll-version-hell