Recently while trying to deploy a service to a clean VM (moving this off our main production server onto its own server) I ran into the error below”
Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'System, Version=22.214.171.124, Culture=neutral,
PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes' or one of its dependencies. The given assembly name or codebase was invali
d. (Exception from HRESULT: 0x80131047)
At first glance I thought it was saying that I did not have .net 2 installed on the server which was odd as it had .NBet 3.5 (which is a superset of 2) and .Net 4. Of course I quickly set out to Bing the hell out of the message but that did not really lead me to an immediate solution. However, what I did notice was that v 126.96.36.199 was always referred to in the context of Silverlight, this got me thinking. Was i referencing a Silverlight based assembly in my project? To find this out I turned to my handy decompiler from Telerik.
Sure enough I did have a silverlight assembly being referenced in .Net (I did not have the silverlight SDK installed on my box). I removed the reference and redeployed, but nothing changed. I still received the error above. Now I was getting pissed. I went back to the decompiler and started looking again through my reference tree to see if I missed something, and I did, kinda. Turns out one of our assemblies is using the Portable Class Library and it is targeted towards the client profile and Silverlight profile, but this should not have caused an issue, but clearly it did.
After a bit more digging the answer showed up. As it turns out the solution to my problem was buried deep on the Portable Class Library documentation page (as seen below), and it pointed me toward the setup file which solved my issue.
Turns out that when you use the Portable Class Library it will actually upgrade/update your .net assemblies on disk in order to use this, which makes sense, and with out running the installed mentioned above you will not be able to use any .net assembly which is based off the Portable Class Library.
The moral of the story is that if you are use PCL then make sure you install the update above on your servers in order to get everything to work.
Till next time,
07-23-2012 5:13 AM