当客户端和服务器在远程处理中共享相同的接口时,如何为 SAO 创建代理

发布于 2024-07-24 09:45:39 字数 378 浏览 0 评论 0原文

我对SAO对象有疑问。 例如。 我有 ITest 接口,它位于 ITestObj.dll 和 RemoteObject(注册为 SAO)测试中,它在名为 RemoteObject.dll 的服务器中实现 ITest。 现在我的客户只使用 ITestObj.dll 并尝试使用 Activator 方法创建代理对象。 根据 MSDN- GetObject 或 new 可用于服务器激活。 需要注意的是,当进行这些调用时,远程对象不会被实例化。 事实上,根本没有生成任何网络调用。 框架从元数据中获取足够的信息来创建代理,而根本不需要连接到远程对象。

为什么 Activator.GetObject 可以创建一个 Test 实例并将其作为 Itest 类型提供给客户端而无需连接到服务器?

I have doubt realted to SAO object.
Fo eg. I have Interface ITest which is in ITestObj.dll and RemoteObject(which is registered as SAO) Test which implements ITest in a server called RemoteObject.dll. Now my client just uses ITestObj.dll and try to create the proxy object using Activator method. As per MSDN-
GetObject or new can be used for server activation. It is important to note that the remote object is not instantiated when either of these calls is made. As a matter of fact, no network calls are generated at all. The framework obtains enough information from the metadata to create the proxy without connecting to the remote object at all.

How come Activator.GetObject can create an instance of Test and give it as a type of Itest to the client wihtout connecting to server?

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

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

发布评论

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

评论(2

乱世争霸 2024-07-31 09:45:39

在您对对象进行调用之前,代理不会尝试连接到服务器。 因此,即使服务器未运行,您也可以使用 Activator.GetObject() 来获取对对象上代理的引用。

如果在服务器未运行时调用代理对象上的方法,您将收到 RemotingException。

The proxy doesn't attempt to connect to the server until you make a call on the object. So even if the server isn't running you can use Activator.GetObject() to get a reference to a proxy on the object.

If you call a method on the proxy object while the server is not running you'll get a RemotingException.

纸伞微斜 2024-07-31 09:45:39

创建客户端透明代理时,不会在服务器上检查其有效性。 一旦调用函数,就会与服务器建立连接,此时服务器会尝试定位实现该接口的服务器对象。 如果未找到,则会生成错误。

基本上,在客户端上创建的透明代理使用接口来确定如何序列化对服务器的调用。

我不确定我是否清楚地解释了这一点,但希望这会有所帮助。

When the client transparent proxy is created it is not checked for validity on the server. Once you invoke a function then a connection is made to the server at which point the server attempts to locate the server object implementing the interface. If it is not found then an error is generated.

Basically the transparent proxy created on the client is using the interface to determine how to serialize the call to the server.

I'm not sure if I'm explaining this clearly, but hopefully this helps.

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