Question

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)

Was it helpful?

Solution

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).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top