Open inmny opened 1 month ago
To get more info about the TypeInitializationException
add a try / catch and log its InnerException
property.
The log should contain the exception class Name
, the Message
and StackTrace
.
In case its InnerException
is not null it should also be logged.
Log code:
LogInfo($"{Type.GetType("UnityEngine.Application, UnityEngine")}");
try
{
_ = new EntityStore();
}
catch (Exception e)
{
do
{
LogInfo($"Name: {e.GetType().Name}\nMessage: {e.Message}\nStackTrack: {e.StackTrace}");
e = e.InnerException;
} while (e != null);
}
Log:
[Info : Unity Log] [NML]: UnityEngine.Application
[Info : Unity Log] [NML]: Name: TypeInitializationException
Message: The type initializer for 'Static' threw an exception.
StackTrack: at Friflo.Engine.ECS.EntityStoreBase..ctor () [0x00022] in <2760b6615674441eb080f0fb778cfc66>:0
at Friflo.Engine.ECS.EntityStore..ctor (Friflo.Engine.ECS.PidType pidType) [0x00000] in <2760b6615674441eb080f0fb778cfc66>:0
at Friflo.Engine.ECS.EntityStore..ctor () [0x00000] in <2760b6615674441eb080f0fb778cfc66>:0
at Cultiway.ModClass.OnModLoad () [0x00002] in Source\ModClass.cs:18
[Info : Unity Log] [NML]: Name: TypeLoadException
Message: Could not resolve type with token 010000aa (from typeref, class/assembly System.Runtime.CompilerServices.RuntimeFeature, netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51)
StackTrack: at Friflo.Engine.ECS.SchemaUtils.RegisterSchemaTypes (Friflo.Json.Fliox.Mapper.TypeStore typeStore) [0x00000] in <2760b6615674441eb080f0fb778cfc66>:0
at Friflo.Engine.ECS.EntityStoreBase+Static..cctor () [0x0000a] in <2760b6615674441eb080f0fb778cfc66>:0
It seems that it is running on NativeAOT. But I am sure that it is in unity runtime.
I find its problem: It tries to load "RuntimeFeature" type which is only provided by "System.Runtime" when call SchemaUtils.RegisterComponentTypesByReflection
no matter whether it is used.
I tried to use your framework(netstandard 2.1) in a unity mod. The mod is compiled and loaded at runtime.
The mod is compiled with "allow unsafe code" on Windows.
Framework version:
Dependencies version:
Log:
Code:
What should I do for more detailed information?