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).