Visual Studio 2010 – DLL Reference path won’t change when remove and re-add reference

On the whole Visual Studio is a great software development tool with a relatively low number of annoying bugs. However, there is one annoying bug that Microsoft doesn’t seem to be bothered enough to fix…

 

The problem happens if you remove and re-add a file reference to a DLL. When you re-add the reference (same file name in a different folder) by browsing to a different file location, Visual Studio will for some reason insist on using the previous file path to the DLL and not the new one!!!

 

You can find some more information about the problem here.

 

We were trying to change a reference’s path by removing and re-add it but it just didn’t work due to this bug!

 

So how can we get around this problem? Well one way is to change the reference path directly by editing the project file.

 

To do this, right click on the project in the solution explorer and choose ‘Unload Project.’ Once the project is unloaded, right-click on it again and then choose ‘Edit’, the project’s XML will be displayed in the editor.

 

Now search for references to the incorrect reference path and change it to your new path. To do this, look near the following elements:
[code lang=”xml”] and [/code]
and:
[code lang=”xml”] and [/code]

 

Finally, right-click on the project again and choose ‘Reload Project’ – check that the references are correct….

 

I hope this helps someone, it was the only way we could figure out how to get around the problem…

 
4 replies
  1. Tristan
    Tristan says:

    So this solution didn’t actually work for me. The HintPath reference was actually updating to the correct path in the XML, but not being reflected in the path variable under the DDL’s properties.
    So what I did was delete the DLL at the location given by the path variable under the properties, and then it updated to the new one.

    Hope this helps someone!

  2. Tim Shearer
    Tim Shearer says:

    This gave me some ideas – the problem I was having what that I couldn’t change the path to ‘Oracle.DataAccess.dll’. I followed your instructions about, edited the XML, commented out

    The section had the correct path. Anyway, I can now change to path as I originally wanted to. My problem is solved.

  3. Terry Clancy
    Terry Clancy says:

    Actually neither worked for me as I had more than two lines in the Project file referencing the DLL I found that the trick is to make sure the one you want in your “Reference” appears FIRST. For example I wanted to Reference bin\log4net.dll so I had to copy that line above the other below in my *.csproj file:

    Terry Clancy
    ClanceZ

Comments are closed.