[SOLVED] SecurityException on embedded .resx when using IL2CPP

I have embedded resources for some localized text in one of our projects DLLs.

Regular .resx files.


When I build with Mono it works fine. The code is able to load my strings from the embedded resource files just fine.

But when I build using IL2CPP, I receive the following error when trying to access the resource:

SecurityException: The public key is not valid.
  at System.Reflection.AssemblyName.get_FullName () [0x00000] in <00000000000000000000000000000000>:0 
  at System.AppDomain.LoadSatellite (System.Reflection.AssemblyName assemblyRef, System.Boolean throwOnError) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Reflection.Assembly.InternalGetSatelliteAssembly (System.String name, System.Globalization.CultureInfo culture, System.Version version, System.Boolean throwOnFileNotFound, System.Threading.StackCrawlMark& stackMark) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Resources.ManifestBasedResourceGroveler.GetSatelliteAssembly (System.Globalization.CultureInfo lookForCulture, System.Threading.StackCrawlMark& stackMark) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet (System.Globalization.CultureInfo culture, System.Collections.Generic.Dictionary`2[TKey,TValue] localResourceSets, System.Boolean tryParents, System.Boolean createIfNotExists, System.Threading.StackCrawlMark& stackMark) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Resources.ResourceManager.InternalGetResourceSet (System.Globalization.CultureInfo requestedCulture, System.Boolean createIfNotExists, System.Boolean tryParents, System.Threading.StackCrawlMark& stackMark) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Resources.ResourceManager.InternalGetResourceSet (System.Globalization.CultureInfo culture, System.Boolean createIfNotExists, System.Boolean tryParents) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Resources.ResourceManager.GetString (System.String name, System.Globalization.CultureInfo culture) [0x00000] in <00000000000000000000000000000000>:0 
...
stacktrace continues with unrelated method calls from our codebase

This is a biggie for our company as resource files would be grand to use but we need IL2CPP as our target platform will be WebGL.

I have used up a day of researching with no succession. Need help on any ideas.

Can upload repr upon request.

This was regarded a bug and has been fixed in 2018.3.10f1 and 2019.1.0b9.

To get it working on 2018.3.10f1 or 2019.1.0b9, you also has to enable the embeddedResources flag, which can be done by following Josh’s guide: https://forum.unity.com/threads/enabling-embedded-resources-with-webgl.326069/
Or by just changing the line webGLUseEmbeddedResources: 0 to webGLUseEmbeddedResources: 1 in your project settings file at ProjectSettings/ProjectSettings.asset.


One more note: as of now, it does not seem to work with strongly named (signed) assemblies. On using GetString on a .resx embedded file it instead returns null.