[mono-android] Non-serializable types in Monodroid?

nodoid paul at all-the-johnsons.co.uk
Mon Nov 28 11:09:12 EST 2011


Hi,

Simple question - other than types not serializable in standard C#, are
there any other additional types which cannot be serialized in Monodroid?

I'm trying to serialize a class (below) using the code below that, but it
dies when I try to serialize the class.

    [Serializable]
    public class common
    {
        public int p, a, w, pa;
        public double bodyWeight, tempBody, tempSurround;
        public double[,] correctionData = new double[3, 20];
        public double[,] iterations = new double[3, 20];
        public double c, b, cas;
        public string s;
    }

and to serialize

    [Activity(MainLauncher = true, Label = "@string/ApplicationName", Theme
= "@android:style/Theme.NoTitleBar")]
    public class AndroidTimeOfDeath : TabActivity
    {
        protected override void OnCreate(Bundle bundle)
        {
            common data = new common();
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Main);
            TabHost.TabSpec spec;
            Intent intent;
            intent = new Intent(this, typeof(TimeTemp));
            intent.AddFlags(ActivityFlags.NewTask);
            XmlSerializer x = new XmlSerializer(data.GetType());
            StringWriter o = new
StringWriter(System.Globalization.CultureInfo.InvariantCulture);
            x.Serialize(o, data);
            // etc
       }

The Serialize crashes and burns with a System.ArgumentException 

The serializer code looks right, so I'm trying to see if there is something
in the class being serialized that Monodroid objects to.

Any help would be appreciated.

Paul

--
View this message in context: http://mono-for-android.1047100.n5.nabble.com/Non-serializable-types-in-Monodroid-tp5029261p5029261.html
Sent from the Mono for Android mailing list archive at Nabble.com.


More information about the Monodroid mailing list