title: Problem using XmlSerializer to Serialize/Deserialize a class between a Silverlight Library and an MVC App
body: <p>Here is my situation:</p>
  <p>I have a solution with three projects: 1) Silverlight App, 2) Silverlight Library, 3) the Asp.net-MVC Web App.</p>
  <p>In the Silverlight Library I have a class called &quot;MyClass&quot;.  In the Silverlight App I serialize that class to XML using XmlSerializer and send the XML back to the database.  I retrieve and deserialize that XML periodically in the Silverlight App to use MyClass.</p>
  <p>My problem comes when I try to deserialize that XML from within the Asp.Net-MVC App.  Inside the Asp.Net-MVC App this is the code I use to deserialize the XML to MyClass:</p>
  <pre><code> MySilverlightLibrary.MyClassObjects.MyClass newMyClass = null;
  
   Assembly ass = Assembly.Load(&quot;MySilverlightLibrary.MyClassObjects&quot;);
   Type ty = ass.GetType(&quot;MySilverlightLibrary.MyClassObjects.MyClass&quot;, true);
  
   XmlSerializer theSerializer = new XmlSerializer(ty);
  
   if( !String.IsNullOrEmpty(xmlText) )
   {
      using( XmlReader sr = XmlReader.Create(new StringReader(xmlText)) )
      {                 
         newMyClass = theSerializer.Deserialize(sr) as MySilverlightLibrary.MyClassObjects.MyClass;
      }
   }  
  </code></pre>
  <p>This is the runtime error I get:</p>
  <blockquote>
  <p>Server Error in '/' Application.</p>
  <p>Could not load file or assembly '<strong>System.Xml</strong>, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. The system cannot find the file specified.</p>
  <p>Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.</p>
  <p>Exception Details: System.IO.FileNotFoundException: Could not load file or assembly 'System.Xml, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. The system cannot find the file specified.</p>
  </blockquote>
  <p>I noticed that the version of the &quot;System.Xml&quot; reference in the Silverlight Library project is 2.0.5.0, but the &quot;System.Xml&quot; reference is 2.0.0.0 in the Asp.Net-MVC App.  I assume that this is likely the cause of the issue, but I can't figure out how to fix it!</p>
  <p>I have been messing with this for quite some time now and it's driving me nuts!  As always, any help would be greatly appreciated!</p>
  <p>Thanks</p>
  <p>Jeff</p>