Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is serializing double[] not working in WinCE?
    primarykey
    data
    text
    <p>I have an Object with (de-)serializes its configuration via system.xml.serializer</p> <p>The config is in a class looking like this:</p> <pre><code> public struct Phase { public Int16 Trafo; public KorrekturWerte Spannung; public KorrekturWerte Strom; [XmlArray("Min")] public double[] Min; [XmlArray("Max")] public double[] Max; public bool CheckThis; } public class ParameterHardware { public string WAGOId = "00:30:DE:05:33:CB"; public Byte Phasen = 0x07; public Phase L1; public Phase L2; public Phase L3; } </code></pre> <p>(De-)Serializing this on a WindowsXP-System works just fine, but on Windows CE, the Min/Max-Array is just mussing after de- and then reserializing ("CheckThis" was put there as a test and follows after serializing the "Strom" values). As KorrekturWerte is again a struct, depth can't be the problem. The [XmlArray ...] wasn't there in my first version, it's just from another test.</p> <p>Edit:</p> <ul> <li><p>The Problem is not (only) in serialization. Trying to access Min[...] I get a null reference error.</p></li> <li><p>Maybe it's not clear: I have a serialization of the class, which contains <em>all</em> values. Deserialize it to initialize the class and then reserialize it as a debug-check. Now the fields are missing. (The original file was serialized in XP, where it works all right)</p></li> <li><p>Changeing the double[] to List does not help. (Same result) </p></li> <li><p>The xml-files: Original:</p> <p> 00:30:DE:05:53:65 1 50 -0.2 1 0.004 0.994 0 0 0 0 0 500 32 15000 15000 1 true 50 0 1 0 1 0 0 0 0 0 500 32 15000 15000 1 50 0 1 0 1 0 0 0 0 0 500 32 15000 15000 1 </p></li> </ul> <p>Reserialization (sorry, CE serializes in one single line):</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;&lt;ClassTest_FCT_Extern xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;&lt;Hardware&gt;&lt;WAGOId&gt;00:30:DE:05:53:65&lt;/WAGOId&gt;&lt;Phasen&gt;1&lt;/Phasen&gt;&lt;L1&gt;&lt;Trafo&gt;50&lt;/Trafo&gt;&lt;Spannung&gt;&lt;Offset&gt;-0.2&lt;/Offset&gt;&lt;Steigung&gt;1&lt;/Steigung&gt;&lt;/Spannung&gt;&lt;Strom&gt;&lt;Offset&gt;0.004&lt;/Offset&gt;&lt;Steigung&gt;0.994&lt;/Steigung&gt;&lt;/Strom&gt;&lt;CheckThis&gt;true&lt;/CheckThis&gt;&lt;/L1&gt;&lt;L2&gt;&lt;Trafo&gt;50&lt;/Trafo&gt;&lt;Spannung&gt;&lt;Offset&gt;0&lt;/Offset&gt;&lt;Steigung&gt;1&lt;/Steigung&gt;&lt;/Spannung&gt;&lt;Strom&gt;&lt;Offset&gt;0&lt;/Offset&gt;&lt;Steigung&gt;1&lt;/Steigung&gt;&lt;/Strom&gt;&lt;CheckThis&gt;false&lt;/CheckThis&gt;&lt;/L2&gt;&lt;L3&gt;&lt;Trafo&gt;50&lt;/Trafo&gt;&lt;Spannung&gt;&lt;Offset&gt;0&lt;/Offset&gt;&lt;Steigung&gt;1&lt;/Steigung&gt;&lt;/Spannung&gt;&lt;Strom&gt;&lt;Offset&gt;0&lt;/Offset&gt;&lt;Steigung&gt;1&lt;/Steigung&gt;&lt;/Strom&gt;&lt;CheckThis&gt;false&lt;/CheckThis&gt;&lt;/L3&gt;&lt;/ClassTest_FCT_Extern&gt; </code></pre> <ul> <li><p>Sorry for bringing everything slice by slice. Here is the serialization code (using System.Xml.Serialization;)</p> <pre><code>try { fstream = new FileStream(filepath, FileMode.Open, FileAccess.Read); reader = new XmlTextReader(fstream); serializer = new XmlSerializer(typeof(T)); retobj = (T)serializer.Deserialize(reader); } catch (Exception e) { Debug("Serialization: "+e.ToString()); retobj = Activator.CreateInstance&lt;T&gt;(); } </code></pre></li> </ul> <p>Debug is not called, so there don't seem to be any errors.</p> <ul> <li>The .net Version is 2.0</li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload