title: FileNotFoundException in Portable Class Library?
body: <p>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 &amp; targeting WP7, SL4 &amp; .NET 4.0) which contains a common type used between the first two.</p>
  
  <p>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:</p>
  
  <blockquote>
    <p>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'</p>
  </blockquote>
  
  <p>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.</p>
  
  <p>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: <strong>Why is this happening? How can I configure the PCL to function as written?</strong></p>
  
  <p>EDIT: A little more information... my  PCL uses <a href="http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializer%28v=VS.95%29.aspx" rel="nofollow">XmlSerializer</a>, 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</p>
  
  <p>In this case, XmlSerializer actually lives in <em>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETPortable\v4.0\Profile\Profile2\System.Xml.Serialization.dll</em> (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:</p>
  
  <blockquote>
    <p>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)</p>
  </blockquote>