Hello,
I have a problem with xml-deserialization and dynamically loaded assemblys. I load my assembly directly from a zip-file to a byte array. Then i load this assembly. The assembly contains a data-model, which should be deserialized with XmlSerializer. The problem is that I always get an TypeInitializationException, if i try to load my xml.
The german exception is following:
System.InvalidOperationException: Fehler im XML-Dokument (62,13). ---> System.TypeInitializationException: Der Typeninitialisierer für "Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderOrder" hat eine Ausnahme verursacht. ---> System.NullReferenceException: Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.
bei Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderOrder..cctor()
If i load my dll directly from a dll-file, and not from a zip into a byte-array, the xml could be sucessfully deserialized.
I the internet i found, that the problem could be Lists with own types, but the solutions i found there didn't solve my problem.
It would be great, if somebody could help me.
Thanks, Martin
EDIT:
I've found that I couldn't use generic Lists with own types, if I load the assembly via byte-array, as it is written on other website. I couldn't say, why I first hadn't success with this solutions, but after a second try it works. I've made a workaround with ArrayList, but im very unhappy with this. Is there a better solution, where I can use generic lists? Or if there isn't a better solution, is there a better Serializer/Deserializer for XML?