2009-11-02 91 views

回答

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."); 

MSDN Docs on IsTransparentProxy

+0

我投這個答案是因爲它提供了有關特定FCL方法的MSDN文檔鏈接,我喜歡看到引用的框架創建者的想法。其他選項可能存在,但Microsoft明確規定了這種方法。 –

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"); 
+0

派生你能告訴我如何做一些更多的細節? TransparentProxy似乎是一個內部類,而且非常透明*。 – eWolf