When Calvin proclaimed that "Life is a lot more fun if you are not responsible for your own actions", I think he missed this side of the coin where you don't know what the "heck" is going on..
I have a solution containing a "decidedly and dedicatedly rotten" project. This project references a 3rd Party component (v1.1) from a specific ExtLib directory. This directory is now embedded as the HintPath in the csproj file. Now the magic starts. I have a CI server (CCNet+ NAnt) running builds on the hour. This build machine has v1.0 and v1.1 of the component registered in the GAC. When I open the solution in the IDE, the rotten project gets the assembly from the GAC and the wrong one to boot (1.0).At runtime, it blows up saying that you do not have a license for 1.0. I have pleaded for a day that I don't want 1.0 take 1.1 it's right there you moron but no deal !
Things I found out today.
I don't know the assembly resolution process of Visual Studio. Here's my study notes though...
* When I add a reference to a project, it stores a relative path in the HintPath property (.csproj file). It then translates the relative path to an absolute path and stores it as a ReferencePath setting in the .csproj.user file.
* When I open the solution again, the IDE just picks up the assembly from the absolute path in the .csproj.user file.
* If I delete the .csproj.user file, the IDE seems to be getting the wrong version of the assembly from the GAC. This leads me to believe that the hintpath property is used only if the assembly is not found in the GAC. This time the .csproj.user file is not created, maybe because the reference was resolved from the GAC.
Now one way to resolve this was to add the ExtLib dir path to the ReferencePath property in Project Settings. This will create the .csproj.user file for you with the absolute path inside it. I don't check in .csproj.user files to SourceControl. So this is a workaround rather than a solution.
Another stunning piece of knowledge was on another machine, there is a dramatic difference. If I delete the .csproj.user file, I found that it automatically got the correct 1.1 DLL from the ExtLib (even though even that machine had 1.0 and 1.1 in the GAC) AND recreated the .csproj.user file automatically.
I'm a ignorant .NET programmer so HELP ME God !!
No comments:
Post a Comment