如何确定对象是本地还是远程(使用C#远程处理)?如果对象是远程的,则检查本地代码,如果从远程执行代码,则检查对象都可以。
答案 0 :(得分:4)
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.");
答案 1 :(得分:0)
我想您可以查看代理,看看它是否来自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");