- Home /
System.Xml.Serialization in UWP with IL2CPP
Hey,
I'm trying to port an existing application to UWP with the IL2CPP backend. It works fine mostly, however we make use of the System.Xml.Serialization and this seems to crash with this setup. I found a related issue here: Unity Issue Tracker
Are there known alternatives or workarounds for this? I basically just need to de-/serialize XML files. I tried ZeroFormatter (see here), but can't yet find a way to give it the string/bytes from a human readable XML file as input.
Thanks and best regards
Answer by JoshPeterson · Jun 06, 2018 at 11:57 AM
You should not need a work around for this issue, at least not in Unity 2018.1 or later. I incorrectly marked that bug report as Won't Fix - sorry about that.
The problem here is managed code in System.Xml.dll that does not place nicely with an AOT compiler (like IL2CPP).
We've corrected this issue in 2018.1 and 2018.2. In those versions of Unity, you will need to use the .Net Standard 2.0 Api Compatibility Level to get the AOT-friendly version of System.Xml.dll. In Unity 2018.3 we will also have an AOT-friendly version of System.Xml.dll for the .NET 4.x Api Compatibility Level.
Answer by CasiaLab · Sep 21, 2018 at 02:11 AM
@JoshPeterson Will it be for the official release because I tried the beta and the problem still seems to persis? .
Hey Josh! sorry to bother you here. I was doing some testing of 2018.3.0b2 and got a consistent crash, instantly, in IL2CPP builds. $$anonymous$$ac. It's so instant there's no reporter come up. Where/how/what you want me to send you to help, if what I have occurring is helpful.
Cheers, and keep up the good work. You're a legend. Single handedly keeping my faith in Unity as an entity ;)
Please drop us a bug report from the Editor. If you can include the project, that will help us reproduce it more quickly, and hopefully fix it.
I am currently using the 2018.3.0b2 version of Unity
This should be working in that version, but maybe you have found a different issue. Can you send us a bug report?
Answer by me_Stoffel · Jun 06, 2018 at 12:12 PM
Aah, thanks, that's very interesting to hear. I actually was using Unity 2017.3 and just upgraded to 2018.1, but using the .NET 4.x api compability level. Will try to go back to 2.0 then and test, if it works with that :) Is the fix for .NET 4.x a save thing to expect for 2018.3?
Yes, this will be corrected in the .NET 4.x Api Compatibility Level only in Unity 2018.3, not before.
Answer by ANTONBORODA · Aug 01, 2018 at 02:56 PM
So currently, there's no reason to use .NET 4.x is you are doing anything related to serialization? Changes aren't going to be back-ported to 2013.2, right? Only 2013.3 will get a fix?
The changes are too risky for a back port. But you can use the .Net Standard 2.0 Api Compatibility Level, which should have just about everything you need for most games. Is there something specific you need in the .NET 4.x Api Compatibility Level?
The specific thing we'd like to use with .NET 4.x without breaking Xml serialization on UWP is Tasks, for the only websocket server library (Fleck) that works with UWP. It looks like less risk to try an Xml alternative than to port our already tested/optimized app to 2018.3.
Your answer
Follow this Question
Related Questions
Confusion with process of XML setup 0 Answers
Asset Bundle code stripping / link.xml not working 1 Answer
Problems with the XML Serializer 1 Answer
unity and xml question 1 Answer
Parse XML to Vector3 (and other objects you don't control) 0 Answers