Search code examples
c#wcfinterfacerealproxy

Calling GetType on service interface causes invoke?


I have a very basic interface for several services. Doing something like:

private static void Test(IService svc)
{
     var test = svc.GetType();
}

while passing in an instance of a remote service that inherits from IService causes the RealProxy Invoke method to be fired.

Why?


Solution

  • As pointed out by stuartd this is expected behavior.

    https://msdn.microsoft.com/en-us/library/system.runtime.remoting.proxies.realproxy.invoke(v=vs.110).aspx