IL2CPP - No constructor found for System.Resources.RuntimeResourceSet

Hello,

I have an app on the app store which was compiled with Mono. It uses the open source TZ4NET .dll for time zone operations. I am able to compile the app and run it however the following line which references the TZ4NET library fails. I’ve tried both the dll and using the code itself and it fails. TZ4NET - http://www.babiej.demon.nl/Tz4Net/main.htm

OlsonTimeZonefromZone = OlsonTimeZone.GetInstanceFromOlsonName(“Etc/UTC”);

Bellow is the error which I am getting. Any help is appreciated as I am stuck on this for a few weeks now. It doesn’t seem that it is a TZ4NET issue since it works fine with Mono.

UnityEngine.Debug:Internal_Log(Int32, String, Object)

UnityEngine.Debug:Log(Object)

MainScript:GetUTCDateTime(String, String, String, String, String, String)

MainScript:PopulateInputGates(String)

MainScript:PrepareInputGates()

MainScript:CalculateHD()

LoadChart:OnPress(Boolean)

UnityEngine.GameObject:SendMessage(String, Object, SendMessageOptions)

UICamera:Notify(GameObject, String, Object)

UICamera:ProcessRelease(Boolean, Single)

UICamera:ProcessTouch(Boolean, Boolean)

UICamera:ProcessTouches()

UICamera:Update()

(Filename: /Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 65)

MissingMethodException: No constructor found for System.Resources.RuntimeResourceSet::.ctor(System.IO.UnmanagedMemoryStream)

at System.ArgumentOutOfRangeException…ctor (System.String paramName, System.String message) [0x00000] in :0

at System.Activator.CreateInstance (System.Type type, BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[ ] args, System.Globalization.CultureInfo culture, System.Object[ ] activationAttributes) [0x00000] in :0

at System.Activator.CreateInstance (System.Type type, System.Object[ ] args, System.Object[ ] activationAttributes) [0x00000] in :0

at System.Activator.CreateInstance (System.Type type, System.Object[ ] args) [0x00000] in :0

at System.Resources.ResourceManager.InternalGetResourceSet (System.Globalization.CultureInfo culture, Boolean createIfNotExists, Boolean tryParents) [0x00000] in :0

at System.Resources.ResourceManager.GetObject (System.String name, System.Globalization.CultureInfo culture) [0x00000] in :0

at System.Resources.ResourceManager.GetObject (System.String name) [0x00000] in :0

at TZ4Net.ZoneInfo.get_AllDirs () [0x00000] in :0

at TZ4Net.ZoneInfo…ctor (System.String name, System.String dir) [0x00000] in :0

at TZ4Net.ZoneInfo…ctor (System.String name) [0x00000] in :0

at TZ4Net.ZoneInfo+Time…cctor () [0x00000] in :0

at TZ4Net.OlsonTimeZone…cctor () [0x00000] in :0

at MainScript.GetUTCDateTime (System.String pCountry, System.String pCity, System.String pYear, System.String pMonth, System.String pDay, System.String pTime) [0x00000] in :0

at MainScript.PopulateInputGates (System.String ChartType) [0x00000] in :0

at MainScript.PrepareInputGates () [0x00000] in :0

at MainScript.CalculateHD () [0x00000] in :0

at LoadChart.OnPress (Boolean isPressed) [0x00000] in :0

at UnityEngine.GameObject.SendMessage (System.String methodName, System.Object value, SendMessageOptions options) [0x00000] in :0

at UICamera.Notify (UnityEngine.GameObject go, System.String funcName, System.Object obj) [0x00000] in :0

at UICamera.ProcessRelease (Boolean isMouse, Single drag) [0x00000] in :0

at UICamera.ProcessTouch (Boolean pressed, Boolean released) [0x00000] in :0

at UICamera.ProcessTouches () [0x00000] in :0

at UICamera.Update () [0x00000] in :0

Rethrow as TypeInitializationException: The type initializer for ‘TZ4Net.ZoneInfo.Time’ threw an exception.

at TZ4Net.OlsonTimeZone…cctor () [0x00000] in :0

at MainScript.GetUTCDateTime (System.String pCountry, System.String pCity, System.String pYear, System.String pMonth, System.String pDay, System.String pTime) [0x00000] in :0

at MainScript.PopulateInputGates (System.String ChartType) [0x00000] in :0

at MainScript.PrepareInputGates () [0x00000] in :0

at MainScript.CalculateHD () [0x00000] in :0

at LoadChart.OnPress (Boolean isPressed) [0x00000] in :0

at UnityEngine.GameObject.SendMessage (System.String methodName, System.Object value, SendMessageOptions options) [0x00000] in :0

at UICamera.Notify (UnityEngine.GameObject go, System.String funcName, System.Object obj) [0x00000] in :0

at UICamera.ProcessRelease (Boolean isMouse, Single drag) [0x00000] in :0

at UICamera.ProcessTouch (Boolean pressed, Boolean released) [0x00000] in :0

at UICamera.ProcessTouches () [0x00000] in :0

at UICamera.Update () [0x00000] in :0

Rethrow as TypeInitializationException: The type initializer for ‘TZ4Net.OlsonTimeZone’ threw an exception.

at MainScript.GetUTCDateTime (System.String pCountry, System.String pCity, System.String pYear, System.String pMonth, System.String pDay, System.String pTime) [0x00000] in :0

at MainScript.PopulateInputGates (System.String ChartType) [0x00000] in :0

at MainScript.PrepareInputGates () [0x00000] in :0

at MainScript.CalculateHD () [0x00000] in :0

at LoadChart.OnPress (Boolean isPressed) [0x00000] in :0

at UnityEngine.GameObject.SendMessage (System.String methodName, System.Object value, SendMessageOptions options) [0x00000] in :0

at UICamera.Notify (UnityEngine.GameObject go, System.String funcName, System.Object obj) [0x00000] in :0

at UICamera.ProcessRelease (Boolean isMouse, Single drag) [0x00000] in :0

at UICamera.ProcessTouch (Boolean pressed, Boolean released) [0x00000] in :0

at UICamera.ProcessTouches () [0x00000] in :0

at UICamera.Update () [0x00000] in :0

UnityEngine.GameObject:SendMessage(String, Object, SendMessageOptions)

UICamera:Notify(GameObject, String, Object)

UICamera:ProcessRelease(Boolean, Single)

UICamera:ProcessTouch(Boolean, Boolean)

UICamera:ProcessTouches()

UICamera:Update()

To clarify:

  • Mono, works fine
  • IL2CPP, compiles but fails at runtime

@pstpetrov

This looks like it is likely a problem with the code stripper. The constructor for System.Resources.RuntimeResourceSet is being removed when it should not be. If you enable byte code stripping with the Mono scripting backend, you may see the same issue.

So, I think it would be best to submit a bug report, if possible. That will help us track down the cause of the problem.

You may be able to work around the issue by explicitly telling the code stripper to preserve this type, using a link.xml file with the following contents:

You can find more details about the link.xml file here: http://docs.unity3d.com/Manual/iphone-playerSizeOptimization.html

@JoshPeterson

I opened a bug report here a few weeks ago:
http://fogbugz.unity3d.com/default.asp?715013_8bcasgavk72db18p

I was thinking that it is a stripping issue, but tried the links.xml with the TZ4NET and not with the mscorlib. Will try it out.

@pstpetrov

Thanks, I’ll ping QA to have a look at this bug report.

@JoshPeterson

I am getting the same error. Anything else I can try?

MissingMethodException: No constructor found for System.Resources.RuntimeResourceSet::.ctor(System.IO.UnmanagedMemoryStream)

I have a a links.xml file in the Assets folder with the following:

<assemblyfullname=“mscorlib”>
<typefullname="System.Resources.RuntimeResourceSet"preserve=“all”/>

@pstpetrov

The file name should be link.xml, not links.xml. Please try that.

@JoshPeterson

Thanks, this fixed the error. However I am getting another error deeper in TZ4NET which doesn’t show up when the project is compiled with Mono (stripping or not). I’ve tried .NET 2.0 and .NET 2.0 Subset.

I’ve also added TZ4NET to the link.xml file. <typefullname="TZ4NET"preserve=“all”/>

When I compile with IL2CPP (.NET 2.0) I get an extra line which has the word Mono in it, which I find strange:
ArgumentOutOfRangeException: Argument is out of range.
Parameter name: Parameters describe an unrepresentable DateTime.
at Mono.Security.PKCS7+ContentInfo.get_ASN1 () [0x00000] in :0

This is the error with IL2CPP (.NET 2.0 Subset)
ArgumentOutOfRangeException: Argument is out of range.

Parameter name: Parameters describe an unrepresentable DateTime.

at System.ArgumentOutOfRangeException…ctor (System.String paramName, System.String message) [0x00000] in :0

at System.DateTime…ctor (Int32 year, Int32 month, Int32 day, Int32 hour, Int32 minute, Int32 second, Int32 millisecond) [0x00000] in :0

at System.DateTime…ctor (Int32 year, Int32 month, Int32 day, Int32 hour, Int32 minute, Int32 second) [0x00000] in :0

at TZ4Net.ZoneInfo+Time.get_DateTime () [0x00000] in :0

at TZ4Net.OlsonTimeZone.get_AllTimeChanges () [0x00000] in :0

at TZ4Net.OlsonTimeZone.CheckLocalTime (DateTime time) [0x00000] in :0

at MainScript.GetUTCDateTime (System.String pCountry, System.String pCity, System.String pYear, System.String pMonth, System.String pDay, System.String pTime) [0x00000] in :0

at MainScript.PopulateInputGates (System.String ChartType) [0x00000] in :0

at MainScript.PrepareInputGates () [0x00000] in :0

at MainScript.CalculateHD () [0x00000] in :0

at LoadChart.OnPress (Boolean isPressed) [0x00000] in :0

at UnityEngine.GameObject.SendMessage (System.String methodName, System.Object value, SendMessageOptions options) [0x00000] in :0

at UICamera.Notify (UnityEngine.GameObject go, System.String funcName, System.Object obj) [0x00000] in :0

at UICamera.ProcessRelease (Boolean isMouse, Single drag) [0x00000] in :0

at UICamera.ProcessTouch (Boolean pressed, Boolean released) [0x00000] in :0

at UICamera.ProcessTouches () [0x00000] in :0

at UICamera.Update () [0x00000] in :0

UnityEngine.GameObject:SendMessage(String, Object, SendMessageOptions)

UICamera:Notify(GameObject, String, Object)

UICamera:ProcessRelease(Boolean, Single)

UICamera:ProcessTouch(Boolean, Boolean)

UICamera:ProcessTouches()

UICamera:Update()

@pstpetrov

I’m not sure about the cause of this issue. It looks like TZ4Net.ZoneInfo+Time.get_DateTime is calling the DateTime constructor with some bad value. I can’t say why that would be a problem with IL2CPP though.

It might be useful to debug the generated C++ code in Xcode, if you’re up to it. You can find details about how to do this here:

http://blogs.unity3d.com/2015/05/20/il2cpp-internals-debugging-tips-for-generated-code/

I suspect that you will want to set an exception breakpoint. Then when this managed exception occurs, look up the call stack to find where TZ4Net.ZoneInfo+Time.get_DateTime calls the DateTime constructor, and see what values it is passing. That might give us a clue.

Eventually, I suspect we will find that this is a bug in IL2CPP, so you could submit report as well.

@JoshPeterson ,

I submitted a bug report 741166 - https://fogbugz.unity3d.com/default.asp?741166_tide89srjbt2k6il

I was wondering if you can follow up with your QA team to look into it.

Thanks a lot for your help!
Petar

@pstpetrov

Yes, I’ve pinged our QA team, they will have a look at this bug. Thanks for submitting it.

@JoshPeterson
Happy New Year :slight_smile:

Do you have any update on this from the QA team? It is still open.

@pstpetrov

Sorry it has been a while, but I don’t have an update yet on this issue. I’ve asked our QA team to look at it again. They should be able to do so soon.