开发者

Don't understand remoting activation

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 she开发者_StackOverflowd 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?)


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜