As per Remote Object definition -Any object outside the application domain of the caller should be considered remote.
RemotingServices.IsObjectOutOfAppDomain -returns false if remote object resides in the same app domain.
In the MSDN article "Microsoft .NET Remoting: A Technical Overview" I found the following statement (in the paragraph "Proxy Objects") about method calls on remote objects:
"...the [method] call is examined to determine if it is a valid method of the remote object and if an instance of the remote object resides in the same application domain as the proxy. If this is true, a simple method call is routed to the actual object."
So I am surprised when the remote object and proxy will reside in the same app domain.
sample example- using System; using System.Runtime.Remoting; using System.Runtime.Remoting.Channels; using System.Runtime.Remoting.Channels.Tcp;
namespace RemotingSamples { public class HelloServer : MarshalByRefObject { public HelloServer() { Console.WriteLine("HelloServer activated"); } public String HelloMethod(String name) { return "Hi there " + name; } } public class Server { public static int Main(string [] args) { // server code ChannelServices.RegisterChannel(new TcpChannel(8085)); RemotingConfiguration.RegisterWellKnownServiceType( typeof(HelloServer), "SayHelloSingleton", WellKnownObjectMode.Singleton);
// client code HelloServer obj = HelloServer)Activator.GetObject( typeof(HelloServer), "tcp://localhost:8085/SayHelloSingleton");
System.Console.WriteLine( "IsTransparentProxy={0}, IsOutOfAppDomain={1}", RemotingServices.IsTransparentProxy(obj), RemotingServices.IsObjectOutOfAppDomain(obj)); Console.WriteLine(obj.HelloMethod("server")); return 0; } } }