There seems to be a bug in Visual Studio 2010 when adding references to Silverlight projects. You can add “regular” .Net references just fine using the add reference dialog. However if you use the browse feature to find a reference in an “unusual” location, Visual Studio is supposed to record that location along with the reference in the .csproj file. It includes the location via the HintPath property.
At my company, we use build machines and we don’t like to install a lot of software on them. So in source control we have a folder (assets\lib) that includes all of the necessary .dll files that we need to build or projects. When we add references to our project, like for a Silverlight control library, we add it from the assets\lib\Silverlight folder, even though that library is installed on my local machine. Anyway, when I tried doing this in Visual Studio 2010 (I’m upgrading our existing 2008 solution), VS 2010 isn’t including the HintPath. If you aren’t careful, you may not realize this is happening. That’s because since the library is installed on my machine, the build works just fine, except it pulls the .dll from the wrong place. If I were to try this build from my build server, it would fail though.
Anyway, here is the workaround. It’s a pain but it works…
<Reference Include="System.Windows.Controls, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" > <HintPath>..\..\..\Assets\lib\Silverlight\System.Windows.Controls.dll</HintPath> </Reference>
When you are done you can verify that it works. Here’s how…
Primary reference "System.Windows.Controls, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35". Resolved file path is "C:\Projects\MC\BackOffice\UI\branches\2010Migration\Assets\lib\Silverlight\System.Windows.Controls.dll". Reference found at search path location "{HintPathFromItem}".
I hope this helps! Good luck and let’s hope they fix this bug soon.
Remember Me
.Net (55) asp.net (8) asp.net mvc (2) Ben (19) Blog (6) C# (7) Code Camp (28) Entertainment (2) Family (21) Fun Stuff (4) General (19) Hiking (1) jquery (1) LINQ (7) Microsoft (15) MOQ (2) Movies (2) MSBuild (2) MVVM (2) NoDeNUG.org (4) NUnit (3) Orbius (2) Philly.Net (49) Sarah (1) Silverlight (14) SQL Server (3) Subversion (2) Tech-Ed 2007 (3) Technology (24) Travel (2) Unit Testing (2) Vista (7) Visual Studio (3) Web (9) Windows 7 (2) Windows Phone 7 (1)
Powered by: newtelligence dasBlog 1.9.6264.0
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.
© Copyright 2012, Andrew Schwam
E-mail