Share via


Run-time exception thrown : System.ArgumentException - Cannot find the interface method on the object instance.

At the time of writing this entry I found 0 (zero) page hits on google and 1 (one) hit on google groups which originally stemmed from microsoft.public.dotnet.framework.remoting.

Surprise, surprise….So hey, what the heck, here’s #2.

You may receive the following error in the command/watch windoww when attempting to evaluate a property/method of a remote object:

Run-time exception thrown : System.ArgumentException - Cannot find the interface method on the object instance.

Basically what’s happening is that the debugger is getting confused since the remote object is being cast to an Interface instead of an object. Generally what happens when you attempt to add a watch expression (or evaulate a command in the command window) for a remote object you get: <error: cannot evaluate field of a proxy object> . This behavior is expected and by design. The debugger will not evaluate any remote expressions.

In the instance where you cast the object returned from Activator.GetObject() to an interface instead of a specific type you run into this problem. Since the returned object is an interface the debugger doesn’t check to see if the underlying object is a _TransparentProxy (remote object) and attempts to call the method/propertly on the underlying object. Since _TransparentProxy most likely doesn’t expose the method/property you’re trying to evaluate you get: Run-time exception thrown : System.ArgumentException - Cannot find the interface method on the object instance.

Ideally what would happen is that the debugger would check to see if the underlying object is a proxy object and then give you the <error: cannot evaluate field of a proxy object> and not the System.ArgumentException.