0

My code:

    //object
    var obj = new object() { ID = 111, Money = 111};

    //this i want serialize/deserialize, this arraylist contains arraylist with objects
    ArrayList SerializeArrayListOfArrayList = new ArrayList();

    ArrayList array = new ArrayList();
    array.Add(obj);
    array.Add(obj);

    SerializeArrayListOfArrayList.Add(array);
    SerializeArrayListOfArrayList.Add(array);


    SharpSerializer serializer = new SharpSerializer(false);
    serializer.Serialize(SerializeArrayListOfArrayList, "file.xml");
    ArrayList arraylist = (ArrayList)serializer.Deserialize("file.xml");

Serialize is ok, but deserialize throws an exception.

Polenter.Serialization.Core.DeserializingException: 'An error occured during the deserialization. Details are in the inner exception.' InnerException InvalidOperationException: Property type is not defined. Property: ""

This I need deserialize with the nuget package SharpSerializer. Only XML serialization. Not .NET XMLSerializer. http://www.sharpserializer.com/en/index.html

I don't know how i can set a property type, does anyone want to help me?

Thx, sorry for my English

UPDATE: every new instance of object

SOLVED THX

Eliahu Aaron
  • 4,103
  • 5
  • 27
  • 37
Černý Adam
  • 3
  • 1
  • 4
  • Using Serializer is slow. You can get faster results (and may be a solution) if you use Xml linq which is faster. You are not getting any responses because you are using Sharp Serializer which others are not using. – jdweng Mar 15 '20 at 09:26
  • In both array lists you are adding the same instance each time. If you have a look in file.xml you will see that for the second instance, instead of seeing another fully serialised instance there is `` which points to the first instance. There is no `name` or `type`, hence the error message. I don't know whether this should work, but do you need to add the same instance multiple times to your array lists? It works fine when you create/add new instances. – davmos Mar 15 '20 at 10:00
  • @jdweng it is good idea, thx. – Černý Adam Mar 15 '20 at 16:52
  • @davmos thank you, this may be a new instance – Černý Adam Mar 15 '20 at 16:53
  • You're welcome :) consider posting the working code as an answer. – davmos Mar 15 '20 at 16:59

0 Answers0