Visual Studio 2013 Reference Build ErrorĀ – I was recently playing around with some code when I switched my solution configuration from Debug to Release. Suddenly, my builds all failed. There was a warning in my Error List that told me that it could not locate one of my references.
The strange thing was that the project built fine in debug mode. The DLL was referenced and the using statements defined. I couldn’t think why my builds would fail in release mode. The solution wasn’t as straightforward as I would have hoped. It seems as though Visual Studio was hinting at the wrong location.
Visual Studio 2013 Reference Build Error Resolved
What do I mean with the previous statement? Well let’s look at the state of my Visual Studio build results.
As you can see from my Error list, Visual Studio was clearly not impressed with the reference to a DLL I had added previously. I need to remind you that this build error only presented itself when I changed from Debug to Release mode.
The second riddle to this whole thing was that the DLL was referenced for my project. I also checked the properties for this DLL and all seemed fine.
When I looked at my using statements at the top of my code file, I could see that the using for my referenced DLL was underlined by the IDE. Something was really wrong with the project.
After a while, I decided to have a look at my csproj file. I did a search for the DLL name and I found a surprising result. In the csproj file, there is a reference to my DLL and a HintPath. When I traced this path, I noticed that the path was wrong. The path was going up 3 levels and then accessing my Dropbox folder.
I then corrected the HintPath by modifying the csproj file in a text editor (SciTE being my favourite) and saved the csproj file. I then reloaded my Visual Studio solution and rebuilt my project. This time, it compiled without any errors.
The error was most likely caused when I moved my Visual Studio project by copying the project to another location. This absolute path reference in the csproj file then caused Visual Studio to fail when trying to find the referenced DLL. I hope that this quick tip can help someone facing a similar problem.