IL2059:将无法识别的值传递给了“System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor”的 type
参数
将一个无法识别的值传递给了 RuntimeHelpers.RunClassConstructor(RuntimeTypeHandle) 的 type
参数。
如果传递给 RunClassConstructor(RuntimeTypeHandle) 的类型不是静态已知的,则剪裁器无法保证目标静态构造函数的可用性。
void TestMethod(Type type)
{
// IL2059 Trim analysis: Unrecognized value passed to the parameter 'type' of method 'System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor(RuntimeTypeHandle type)'.
// It's not possible to guarantee the availability of the target static constructor.
RuntimeHelpers.RunClassConstructor(type.TypeHandle);
}