의 생성자를 해결하려고 할 때 :System.BadImageFormatException 나는 다음과 같은 코드에 문제가 System.Collections.Generic.GenericComparer`1
var type1 = typeof(object);
var type2 = type1.Module.GetType("System.Collections.Generic.GenericComparer`1");
var constr = type2.GetConstructor(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null);
var byteArray = constr.GetMethodBody().GetILAsByteArray();
var result = type2.Module.ResolveMethod(BitConverter.ToInt32(byteArray, 2));
매번 나는 그것이 나에게 다음과 같은 오류를 제공하여 실행 :
를An exception of type 'System.BadImageFormatException' occurred in mscorlib.dll and wasn't handled before a managed/native boundary
Additional information: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
그러나
var type2 = type1.Module.GetType("System.Collections.Generic.GenericComparer`1");
의 insteaf 나는 기본 클래스를 사용하는 경우
var type2 = type1.Module.GetType("System.Collections.Generic.Comparer`1");
"ResolveMethod"가 OK를 반환합니다.
누구나 그 클래스를 "해결"할 수없는 이유를 알고 있습니까?
감사합니다.
, 둘 다 오류를 제공합니다. 나는 그 일과 관련이 없다고 생각합니다. – Florin
아마도'GenericComparer'가 내부적일까요? –
그렇게 생각하지 마십시오 .. System.Collections.StructuralComparer도 내부적으로 시도했는데 작동합니다 .. – Florin