Android exception during XmlSerializer

Hi,

I deserialize xml data using this code:

XmlSerializer serializer = new XmlSerializer (typeof(ArrayList), new Type[] { typeof(GameProperties), typeof(Class1), typeof(Class2)});

This is working perfectly on windows and OSX, but on Android i receive the following errore at the previous line code:

 An exception was thrown by the type initializer for System.Xml.Serialization.XmlSerializer

System.Configuration.ConfigurationErrorsException: Error Initializing the configuration system. ---> System.MisdException: Method not found: 'Default constructor not found...ctor() of System.Configuration.ExeConfigurationHost'.
       at System.Activator.CreateInstance (System.Type type, Boolean nonPublic) [0x00000] in <filename unknown>:0
       at System.Activator.CreateInstance (System.Type type) [0x00000] in <filename unknown>:0
       at System.Configuration.InternalConfigurationSystem.Init (System.Type typeConfigHost, System.Object[] hostIni
     in <filename unknown>:0
       at System.Configuration.InternalConfigurationFactory.Create (System.Type typeConfigHost, System.Object[] host
    arams) [0x00000] in <filename unknown>:0
       at System.Configuration.ConfigurationManager.OpenExeConfigurationInternal (ConfigurationUserLevel userLevel,
    Assembly calling_assembly, System.String exePath) [0x00000] in <filename unknown>:0
       at System.Configuration.ClientConfiguration

Can you tell me how to fix this?
Any ideas?

Thanks!!

any idea?

I don't know about android but I tried Serialization / serialize data in Unity iOs I had the same problem with Serialization. Though I cannot find any solution to this

2 Answers

2

I’ve found a possible solution!

As described here, just set the Stripping Level to “Disabled” in the Player Settings for Android devices…

I still don’t know what’s this stripping level, but for now it works! :smiley:

I too had this problem, specifically when trying to add PubNub to my project. The Unity stripper is not detecting that PubNub is using http, and removing the initialization code believing it is unused. This appears to be a Unity bug. Making the stripping level “disabled” solved it for me too, but of course, you loose the optimization provided by the code stripper.