代码之家  ›  专栏  ›  技术社区  ›  eflorico

远程处理-对象是远程的吗?

  •  1
  • eflorico  · 技术社区  · 15 年前

    如何确定对象是本地的还是远程的(使用远程处理)?如果对象是远程的,则签入本地代码;如果代码是从远程执行的,则签入对象也可以。

    2 回复  |  直到 15 年前
        1
  •  4
  •   brendan    15 年前
        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

        2
  •  0
  •   Preet Sangha    15 年前

    我想你可以看看这个代理,看看它是否来自 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");