2
votes

I have 3 assemblies, a WP7 app (targeting 7.0), a Web Services project (running 4.0), and a Portable Class Library (built from the template & targeting WP7, SL4 & .NET 4.0) which contains a common type used between the first two.

When run locally (in IIS Express) things work just fine, however when run against a deployed instance of the Web Services assembly (on a remote IIS server I have little control of) fails with the following exception:

System.IO.FileNotFoundException: Could not load file or assembly 'System.Xml.Serialization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified. File name: 'System.Xml.Serialization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Xml.Serialization, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Retargetable=Yes' or one of its dependencies. The system cannot find the file specified. File name: 'System.Xml.Serialization, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Retargetable=Yes'

The stacktrace indicates that it is on the first call into the PCL, which would make sense if it's a type load failure like above.

If I remove the reference to the PCL assembly and then add the key class file to both assemblies, things work fine, however I want to avoid this kind of code duplication... so the question is: Why is this happening? How can I configure the PCL to function as written?

EDIT: A little more information... my PCL uses XmlSerializer, something that lives in System.Xml.dll on the desktop, and in System.Xml.Serialization.xml in Silverlight... an assembly that doesn't exist under the full desktop framework... so this failure makes some sense, only in the PCL world, some of these assemblies/classes are broken out on their own

In this case, XmlSerializer actually lives in C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETPortable\v4.0\Profile\Profile2\System.Xml.Serialization.dll (which is referenced by the PCL)... as a test I added the same reference to the Web Project... however at runtime of the web project, it fails with yellow screen of death stating that:

Could not load file or assembly 'System.Xml.Serialization' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

1
Have you verified that the app pool that your web service is running in on the remote server is set up to use the same .NET version as in your local environment?M.Babcock
You'll want to debug this using the Fusion log viewer. Just make sure to run it as admin, turn on the log, and reboot before attempting to debug. You'll see where the CLR is looking for the assembly, and what version, and from there determine why it isn't being found (if you even have it installed).user1228
@M.Babcock. Both the remote server & local IIS Express instance are running under 4.0.30319.239.Brendan Grant
@Will. Because the remote server is a shared web host, I do not have access to those kinds of logs, nor access to the registry to tweak the key to enable that.Brendan Grant
@BrendanGrant: Hmm, seems like the server doesn't have the right assemblies installed.user1228

1 Answers

3
votes

You will need to install KB2468871 on the remote server. It's a GDR that has been pushed to most client machines - however, servers will need to opt into it (they typically don't automatically install updates).