Remoting - Is an object remote?
How can I determine whether an object is local or remote (using C# remoting)? Both checking in local code if the object is remote or in the 开发者_StackOverflow社区object if the code is executed from remote would be okay.
if(System.Runtime.Remoting.RemotingServices.IsTransparentProxy(myObject))
Console.WriteLine("Yay - my object is a remoted object.");
else
Console.WriteLine("Boo - my object is not a remoted object.");
MSDN Docs on IsTransparentProxy
I suppose you could look at the proxy and see if it derived from TransparentProxy
var myObj = ....;
if(myObj is TransparentProxy)
Console.WriteLine("I have a remote object");
else
Console.WriteLine("I don't think I have a remote object");
精彩评论