I am trying to call the following MSIL method:
.method public hidebysig static bool IsRuntimeType(class [mscorlib]System.Type 'type') cil managed {
.maxstack 2
ldarg.0
isinst [mscorlib]System.RuntimeType
ldnull
cgt.un
ret
}
However, this exception occurs when trying to execute a line:
isinst [mscorlib]System.RuntimeType

Yes, I know about JIT validation, but I tried a lot of things and they didn't work, or maybe I just did it wrong, I'm not sure. In addition, I could not learn much about this subject.
I tried the following (in combination of some of them):
- Add attribute
[SecurityPermissionAttribute(SecurityAction.Demand, SkipVerification = true)]to method (also with SecurityAction.Assert) - Call
new ReflectionPermission(ReflectionPermissionFlag.MemberAccess | ReflectionPermissionFlag.RestrictedMemberAccess).Demand();(as well .Assert()) - Call
new SecurityPermission(SecurityPermissionFlag.AllFlags).Demand();(as well .Assert())
None of these demanding and affirmative people made an exception.
To clarify this, this is just an example. The main idea is to get the code to work and bypass the JIT check. This particular method cannot be executed in C # without reflection, and I want to avoid it because it is very expensive, but it is not.
JIT- TypeAccessException (, , true skipVerification) )?