2

I am intending to serialise a two dimensional array. As recommended here to provide it as a jagged array, and compose it back from a jagged array:

        [XmlIgnore]
        public Rational[,] tab;

        public Rational[][] Data
        {
            get 
            {
                Rational[][] dt = new Rational[tab.GetLength(0)][];
                for (int i = 0; i < tab.GetLength(0); i++)
                {
                    dt[i] = new Rational[tab.GetLength(1)];
                    for (int j = 0; j < tab.GetLength(1); j++)
                        dt[i][j] = tab[i, j];
                }
                return dt;
            }
            set
            {
                tab = new Rational[ value.Length, value[0].Length ];
                for (int i = 0; i < tab.GetLength(0); i++)
                    for (int j = 0; j < tab.GetLength(1); j++)
                        tab[i, j] = value[i][j];
            }
        }

The type Rational represents a fraction that can be in decimal float or a/b integers fraction format. I did separate serialisation for Rational, and it has no problem with this type.
I get this exception in the place where XmlSerializer is constructed:
enter image description here
It is thrown exactly in this place:

        XmlSerializer serializer = new XmlSerializer(typeof(SistemEcuatii));

And here is the code containing the serializer

    class SistemEcuatiiModel
    {
        string baza;
        XmlSerializer serializer = new XmlSerializer(typeof(SistemEcuatii));
        SistemEcuatii data;
        public void WriteTo()
        {
            TextWriter writer = new StreamWriter(baza);
            serializer.Serialize(writer, data);
            writer.Close();
        }
        void LoadFromFile()
        {
            StreamReader streamer = new StreamReader(baza);
            SistemEcuatii dt = (SistemEcuatii)serializer.Deserialize(streamer);
            streamer.Close();
            data = dt;
        }

Searching similar info on internet did not provide some useful information:
net-core-3-1-soap-platform-not-supported-error-compiling-jscript-csharp-script
Docs dot microsoft dot com
I tried suggestion from github issues, but still can't make it working

1
  • 1
    I faced with the same issue recently and would suggest you to create XML with the desired structure and then push it to the XSD tool (learn.microsoft.com/en-us/dotnet/standard/serialization/…). This tool will create XSD for your XML and also generate classes you can use for your task. Commented Jun 27, 2022 at 8:44

1 Answer 1

4

The suggestion from github issues works, no need to worry about that

        [XmlArrayItemAttribute(typeof(Rational[]))]
        public Rational[][] Data
        {
            get 
            {
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.