tags:

views:

59

answers:

3

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; } } }

A: 

Well, one obvious case when it will return false is when the object isn't a proxy, but is a regular .NET object in the local domain (no remoting involved).

I don't understand the MSDN note fully, either ;-p

Marc Gravell
A: 

Thnx for reply. then y remotingservices contain that method which tells whether obj is out of appdoamin or not, if there is no remoting involved. the msdn article states tht if proxy and remote object resides in the same app domain(as far as i know proxy will only be created if remote object is in diff ap domain n an object can be called as remote if it is in diff app domain) then RemotingServices.IsObjectOutOfAppDomain will return false. I hope it clarifies, so i m surprised when tht situation(remote object and proxy is in same app doamin)

A: 

I donot uderstand it either any geniou can help?

Nishant