Hello!
I am finding the error message on the title when compiling for Android with IL2CPP.
*It works ok in editor and on Android if I select Mono as scripting backend instead of IL2CPP.
Inner Exception: linked away
Exception: The type initializer for ‘MyClass’ threw an exception.
I have something like this in code:
public class MyClass : MyBaseClass
// singleton
public static readonly MyClass Instance = new MyClass();
// private constructor
private MyClass()
{
// Do things
}
Thanks!
Does the code above throw the exception? If not, can you post the full code where you are having the problem (minimum repro case)?
Hi, I just submitted a bug to Unity.
What is “MyBaseClass”? Are you sure you didn’t derive your MyBaseClass class from MonoBehaviour or ScriptableObject?
Since you initialize an instance in your static field initializers you essentially call your contructor during your type initialization. Since you stripped all your code from your constructor, how can we tell what’s the issue?
After checking the code, the problem wasn’t with the static constructor itself; but with what I was doing in it.
The issue happens when you create a derived class from System.Data.DataTable and compile for Android under IL2CPP.
I created a fresh new project (2019.4.5f1) where the crash happens always (at least in my system). In case anyone is interested:
https://drive.google.com/file/d/1Z9K_JMUpBtmxzU74LDhQUnxLHLtz8IRi/view?usp=sharing