不明白远程激活

发布于 2024-09-09 00:24:26 字数 630 浏览 4 评论 0原文

我一直在 http://msdn.microsoft.com/en-us/library/kwdt6w2k(v=VS.71).aspx,我不明白一些事情,希望这里有人可以摆脱一些光。

在“构建基本 .NET 远程处理远程应用程序”部分中,描述了三个程序集:

  1. 位于类库 .DLL 中的远程类型

  2. 主机应用程序中,并引用 远程类型类库

  3. 客户端应用程序

    客户端应用程序包含类似的行(此处为 C#)

    RemotableType remotableObj = new RemotableType();

为了编译该行,客户端应用程序必须引用远程类型类库......对吗?而且,如果它具有对该类型定义的引用,为什么该行不只是在进程中实例化 RemotableType 呢?我不明白 RemotableType 实例如何加载到主机应用程序的应用程序域中。

请赐教(或引导我找到更具介绍性的参考资料?)

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?)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浮世清欢 2024-09-16 00:24:26

是的,客户端必须具有对包含远程类的类型信息的程序集的引用。这里的标准做法是创建一个单独的程序集,其中仅包含远程类的接口。客户端和服务器都引用该程序集。服务器包含远程类的实现,但客户端只能看到接口。

客户端在服务器上实例化远程对象的原因是由于 app.config 文件中包含的条目。

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

这里的关键信息是 标签。有关详细信息,请参阅此文章

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文