views:

543

answers:

4

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!

+8  A: 

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.

Darin Dimitrov
+1, ...and make sure to tick the local option for each shared reference inside Visual Studio.
Johannes Rudolph
Just tried that, but it doesn't work - a previous version is still being pulled in.
Mr Shoubs
...No assemblies in GAC
Mr Shoubs
It was a good idea, but didn't work :( what possible places could it be getting this previous verion from? I triple checked I copied the correct file.
Mr Shoubs
Is the assembly listed in the .NET tab of Visual Studio’s Add Reference dialog? This is not the same as the GAC. If so, even if you reference an assembly through the Browse tab VS may use the Registry to find the file. This has cost me hours. I really wish Microsoft would give developers full control over the build, and fail the build if an assembly is not found (rather than trying to find it).
TrueWill
It isn't in the GAC but it is in the .net tab... and personally I think they should fail the build if the assembly is the wrong Major version.
Mr Shoubs
If no version of the assembly is in the GAC and you have removed the reference to the library in your project's Reference's list and re-added it to point only to the dll in the /lib folder, there is no way the version could be anything other than what is in that folder unless you did not do that same procedure for all projects in the solution that have a reference to the DLL. Each project that needs to reference that DLL needs to use a local /lib folder.
Thomas
I'd like you to be correct, but your not :(
Mr Shoubs
@Mr Shoubs - I'm with you on this one. Try removing the Registry key (after making a backup) to remove the assembly from the .NET tab. See http://support.microsoft.com/kb/306149
TrueWill
Interesting - though I don't see how it helps my problem? I thought I would give it the benefit of the doubt, but that path doesn't exist in my registry - I get to HKCU\Software\Microsoft, then there is no .Net datafolder...
Mr Shoubs
A: 

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

Rowland Shaw
Unfortuanly that isn't possible in our scenario, we have to reference the DLL files. (I wish this wasn't the case)
Mr Shoubs
A: 

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.
sankar
I'd vote for this on style, but I've not got 15 rep points yet.1 - shows correct path2 - doesn't seem to make any difference at all3 - already done, sometimes this does solve some problems with compilation, but not this problem4 - I can't find out where in process explorer it tells me this
Mr Shoubs
1. I guess I forgot to mention this, compile and run the application and you can see where it is loaded from in output windows.2. It is best to keep in the shared folder as Darin mentioned. So that, you can remove the bin and obj folder to always regenerate the executable file to make sure that we run with fresh copy of application.4. You mentioned that it picks the wrong assembly from somewhere right? Using this tool, you can just view the referenced assemblies of an application and see where it is loaded from and its version number and etc in runtime.
sankar
5. Additionally, open your project file in Notepad and see if there is any hardcoded version number or hintpath is there. If yes, remove them and add correct version number.
sankar
There is:<Reference Include="VHC.Connections, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> <HintPath>..\..\..\vhc.server.solution\vhc.connections\Tags\v_3_0_0_5\bin\Debug\VHC.Connections.dll</HintPath> </Reference>but changing it makes no difference
Mr Shoubs
Ok, did you use Process Explorer utility?
sankar
In process explorer I can't see where you can find referenced assemblies - I right click on the app, click properties, nothing to do with refereced assemblys in there...
Mr Shoubs
A: 

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.

lm28912