Reputation: 3415
I have a method in class which returns a custom type. I am using reflection to invoke this method but not able to get the response.
NOTE: I cannot cast the return value to the custom type because I cannot refer the dll in my project.
Response = method.Invoke(instance, new[] { parameter});
Response
is null now. this method call should return a custom type.
Upvotes: 1
Views: 1412
Reputation: 564481
You'll get the response as a System.Object
:
object response = method.Invoke(instance, new[] { parameter });
There are multiple reasons you could still get null
for response, including that the method itself returned null
or it was a void
method.
Upvotes: 1