문제

Hi I have object which contains method:

{Boolean Deserialize(System.String, HardwareItemDescriptionControlDriver ByRef)}

when i am trying to find this method:

 Type elementType = typeof(HardwareItemDescriptionControlDriver);

 typesParameters = new Type[] { typeof(String), elementType.MakeByRefType() };
 methodInfo = elementType.GetType().GetMethod("Deserialize", typesParameters);

methodInfo is null

I cant see where can be the problem - I also tryied to find this method with parameters:

typesParameters = new Type[] { typeof(String), elementType }; 

but it doesnt work neither, thanks!

도움이 되었습니까?

해결책

You have a redundant GetType(); elementType is already the Type:

 methodInfo = elementType.GetMethod("Deserialize", typesParameters);

With the extra GetType(), you are asking whether System.Type (or more likely, RuntimeType) has that method (which: it doesn't).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top