Question

I'am using reflection for make a call to WCF service:

var client = new CommonServiceClient();
var thisType = client.GetType();
var theMethod = thisType.GetMethod(methodName);
var resultType = theMethod.ReturnType;
resultType result = theMethod.Invoke(client, parameters.Select(param => param.Value).Cast<object>().ToArray());

So, i want that local result be a type of resultType, but this code produce intelliSense error 'cannot resolve symbol resultType'

Was it helpful?

Solution

AFAIK, you can't do this. Your options as I see it are:

  1. Continue to use reflection on your result object.

  2. If you know that all possible result types are from common base class or share an interface then you can cast to that and use it's methods and properties.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top