-
Notifications
You must be signed in to change notification settings - Fork 383
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
InvalidProgramException: locals size too big #1016
Comments
I have no experience with Units.NET in Blazor WebAssembly, but my hunch is that either AOT strips it out, or webassembly stumbles on our large number of types and methods/properties in the library. IL2CPP in Unity3D apparently had similar issues. Since it seems to crash on UnitConverter ctor, which is default, I suspect it is really having trouble with the static ctor: We load tons of things there. Maybe it is too slow? Maybe it uses too much memory? The only relevant hit on Google was this, which seems to deal with large arrays. We have large dictionaries. Nothing crazy large, but definitely large. |
If you are able to debug with source code, it would be helpful to try to comment out the static ctor or reduce the amount of data it loads to see if it helps. |
The only thing I can think of is just the sheer size of this method. I created PR #1018 to see if this would help. Unfortunately I have no way to test if this fixes it or not, so please give it a go. |
Ref #1016 Instead of a huge single method in UnitConverter, it is split up into a static method per quanitity type.
It works great except for the UnitConverter. Whenever I try one of the examples:
double d1 = UnitConverter.Convert(1, LengthUnit.Centimeter, LengthUnit.Millimeter); // 10 mm
double d2 = UnitConverter.ConvertByName(1, "Length", "Centimeter", "Millimeter"); // 10 mm
double d3 = UnitConverter.ConvertByAbbreviation(1, "Length", "cm", "mm"); // 10 mm
I get the following error:
blazor.webassembly.js:1 crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
Unhandled exception rendering component: The type initializer for 'UnitsNet.UnitConverter' threw an exception.
System.TypeInitializationException: The type initializer for 'UnitsNet.UnitConverter' threw an exception.
---> System.InvalidProgramException: Unable to run method 'void UnitsNet.UnitConverter:RegisterDefaultConversions (UnitsNet.UnitConverter)': locals size too big.
at UnitsNet.UnitConverter..cctor()
--- End of inner exception stack trace ---
Has anyone else had this issue?
The text was updated successfully, but these errors were encountered: