views:

24

answers:

1

I have been working my way through the .NET Remoting Overview at http://msdn.microsoft.com/en-us/library/kwdt6w2k(v=VS.71).aspx , and I don't understand a couple of things, hope someone here can shed some light.

In the Building a Basic .NET Remoting Remoting Application section, three assemblies are described:

  1. a remotable type, living in a class library .DLL
  2. a host app, with a reference to the remotable-type class library
  3. a client app

    The client app contains a line like (C# here)

    RemotableType remotableObj = new RemotableType();

In order for that line to compile, the client app has to have a reference to the remotable-type class library...right? And, if it has this reference to that type definition, why isn't that line just instantiating the RemotableType in-process, as it were? I don't understand how the RemotableType instance is getting loaded in the host app's app domain.

Please enlighten (or direct me to a more introductory reference?)

+1  A: 

Yes, the client must have a reference to the assembly containing the type information of the remote class. The standard practice here is to create a separate assembly that contains only an interface for the remote class. Both the client and the server reference the assembly. The server contains the implementation for the remote class, but the client only sees the interface.

The reason the client instantiates the remote object on the server is due to the entries contained in the app.config file.

<configuration>
   <system.runtime.remoting>
      <application>
         <client 
            url = "http://www.cpandl.com"
            displayName="MyApplication"
         >
            <activated 
               type = "myClientActivatedType,myAssembly"
            />
         </client>
      </application>
   </system.runtime.remoting>
</configuration>

The key piece of information here is the <activated> tag. See this article for more information.

Brian Gideon