Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7547707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T09:31:16+00:00 2026-05-30T09:31:16+00:00

I have an Object with (de-)serializes its configuration via system.xml.serializer The config is in

  • 0

I have an Object with (de-)serializes its configuration via system.xml.serializer

The config is in a class looking like this:

    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;
    }

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

Edit:

  • The Problem is not (only) in serialization. Trying to access Min[…] I get a null reference error.

  • Maybe it’s not clear: I have a serialization of the class, which contains all 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)

  • Changeing the double[] to List does not help. (Same result)

  • The xml-files:
    Original:

    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

Reserialization (sorry, CE serializes in one single line):

<?xml version="1.0" encoding="utf-8"?><ClassTest_FCT_Extern xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><Hardware><WAGOId>00:30:DE:05:53:65</WAGOId><Phasen>1</Phasen><L1><Trafo>50</Trafo><Spannung><Offset>-0.2</Offset><Steigung>1</Steigung></Spannung><Strom><Offset>0.004</Offset><Steigung>0.994</Steigung></Strom><CheckThis>true</CheckThis></L1><L2><Trafo>50</Trafo><Spannung><Offset>0</Offset><Steigung>1</Steigung></Spannung><Strom><Offset>0</Offset><Steigung>1</Steigung></Strom><CheckThis>false</CheckThis></L2><L3><Trafo>50</Trafo><Spannung><Offset>0</Offset><Steigung>1</Steigung></Spannung><Strom><Offset>0</Offset><Steigung>1</Steigung></Strom><CheckThis>false</CheckThis></L3></ClassTest_FCT_Extern>
  • Sorry for bringing everything slice by slice. Here is the serialization code (using System.Xml.Serialization;)

    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<T>();
     }
    

Debug is not called, so there don’t seem to be any errors.

  • The .net Version is 2.0
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T09:31:18+00:00Added an answer on May 30, 2026 at 9:31 am

    Your min/max array must be initialized with new double[] or its null and you have nullref exceptions and missing fields. Null values are not serialized and are missing.

    Edit2:

    Seems like there is a problem deserializing arrays/lists for you. Please make the tag names of the array items more explicite like this:

      [XmlArray("Min")]
      [XmlArrayItem("Value")]
      public double[] Min;
      [XmlArray("Max")]
      [XmlArrayItem("Value")]
      public double[] Max;
    

    and try if that helps you.

    Edit3

    From what you described in our discussion and chat you must have encountered a real bug in .NET Compact Framework 2.0.

    So propably your best bet is to use a custom Deserializer under CE, if you can’t update the Framework.

    There were also some other bugs reported under CE here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class that looks like this: public class MyModel{ public int TheId
I have a .NET application which serializes an object in binary format. this object
I have a class that serializes a set of objects (using XML serialization) that
I am using a class library which represents some of its configuration in .xml.
I have an object I can serialize to XML without a problem. However when
Basically, I have a class with 2 methods: one to serialize an object into
I have been trying to serialize a pretty big object. This object uses dictionaries
I have an XML file that I'm trying to serialize into an object. Some
I have an xml file.i need to serialize to c# class. <Configs> <Services> <Path>
I have a web service which returns something of type MyData . public class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.