XmlSerializer 'Compiling JScript/CSharp scripts is not supported'

Viewed 1359

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 Answers

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

        [XmlArrayItemAttribute(typeof(Rational[]))]
        public Rational[][] Data
        {
            get 
            {
Related