Getting 'exception has been thrown by the target of an invocation' Exception while calling a WCF method using Reflection
Hi,
I'm getting "exception has been thrown by the target of an invocation" while calling a wcf service method at the client side using reflection.
I'm getting the exception while invoking the method at the line:
object result = oMeth.Invoke(oProxy,@params);
Here is my service :
public string GetData(int value)
{
return string.Format("You entered: {0}", value);
}
my client side code:
ChannelFactory<WcfService1.IService1> myFactory = default(ChannelFactory<WcfService1.IService1>);
myFactory = new ChannelFactory<WcfService1.IService1>(new BasicHttpBinding(), "http://localhost:3250");
object oProxy = myFactory.CreateChannel();
Type oType = oProxy.GetType();
MethodInfo oMeth = oType.GetMethod("GetData");
object[] @params = { 3 };
object result = oMeth.Invoke(oProxy,@params);
Plz help if know the solution.
Thanks & Regards,
Ramana