title: C# Serialization / Deserialization between compact .net and regular .net
body: <p>I'm currently trying to solve a wierd problem. one which i cant find much information about.</p>
  
  <p><strong>in short:</strong></p>
  
  <p>When deserializing a xml serialzed object i get a instance of the correct object type, but i only get default values inside the object.</p>
  
  <p><strong>the longer story:</strong></p>
  
  <p>Serialization and deserialization happens on two different platforms.
  One is the .net compact framework (for a windows mobile phone), the other is the regular .net framework.</p>
  
  <p>Serializing and then deserializing on the same platform yields a correctly filled object, the problem only occurs when a serialized string is sent to the other platform.</p>
  
  <p>I have also gotten test xml files from another service that will provision my service with data, these xml files deserialize correctly.</p>
  
  <p><strong>specifics:</strong></p>
  
  <p>The generated XML differ slightly between platforms. ( Note, these are fragments from the internal xml structure where i have identified reoccurring differences. Read: Unit is not a root node ) </p>
  
  <p>Client (Phone, Compact framework)</p>
  
  <pre><code>&lt;Unit&gt;
      &lt;UnitId xmlns=""&gt;555&lt;/UnitId&gt;
      &lt;VehicleId xmlns=""&gt;555&lt;/VehicleId&gt;
      &lt;EmployeeId xmlns=""&gt;004&lt;/EmployeeId&gt;
  &lt;/Unit&gt;
  </code></pre>
  
  <p>Server (Regular .net server)</p>
  
  <pre><code>&lt;Unit xmlns=""&gt;
      &lt;UnitId&gt;555&lt;/UnitId&gt;
      &lt;VehicleId&gt;555&lt;/VehicleId&gt;
      &lt;EmployeeId&gt;004&lt;/EmployeeId&gt;
  &lt;/Unit&gt;
  </code></pre>
  
  <p>From parent system (Unknown platform)</p>
  
  <pre><code>&lt;Unit&gt;
     &lt;UnitId&gt;308&lt;/UnitId&gt;
     &lt;VehicleId&gt;307&lt;/VehicleId&gt;
     &lt;EmployeeId&gt;ASA 500&lt;/EmployeeId&gt;
  &lt;/Unit&gt;
  </code></pre>
  
  <p>Also, instead of setting the standard namespace (xmlns) the parent system uses a prefix in the root node, like this:</p>
  
  <pre><code>&lt;amg:RequestFinishRoute xmlns:amg="http://beans.order.integration.tt.transware.se/order/trackingFinishRoute"&gt;
  </code></pre>
  
  <p>while the data we create by serializing gives:</p>
  
  <pre><code>&lt;RequestFinishRoute xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://beans.order.integration.tt.transware.se/order/trackingFinishRoute"&gt;
  </code></pre>
  
  <p>I use a:</p>
  
  <pre><code>System.Xml.Serialization.XmlSerializer
  </code></pre>
  
  <p>Serializer to do serialization / deserialization(only supported serializer in compact framework).</p>
  
  <p>The code to do this is generated by xsd2code. </p>
  
  <p><strong>question:</strong></p>
  
  <p>Anyone have any tips or resources about this problem?</p>