多重远程对象问题 [英] multiple remoting object problem

查看:46
本文介绍了多重远程对象问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友,

我正在做一个远程应用程序.我有3个班级(学生,老师,学科)将用作远程对象.

我只有1个主机应用程序.代码如下:

Dear friend,

I am doing a remoting application. I have 3 classes (students, teachers, subjects) which will be used as remote object.

I have only 1 host application. Code is the following:

Imports System
Imports System.Runtime.Remoting

Public Class MyHost
    Public Shared Sub Main()
        RemotingConfiguration.Configure("MyHost.exe.config", false)
        Console.WriteLine("Listening for requests. Press enter to exit...")
        Console.ReadLine()
    End Sub
End Class



.config文件是




and the .config file is


<configuration>
   <system.runtime.remoting>
      <application>
         <service>
            <wellknown>
               mode="Singleton"
               type="MyRemoteClass, MyRemoteClass"
               objectUri="MyRemoteObject.rem"
            />
         </wellknown></service>
         <channels>
            <channel ref="tcp" port="8989" />
         </channels>
      </application>
</system.runtime.remoting>
</configuration>




使用同一主机,如何在运行时使用这3个远程对象?或者,我需要针对单个对象的单个主机吗?

请帮帮我.

谢谢您的期待.

问候
Saumitra.




Using the same host, how can i use those 3 remote objects in runtime? or, do i need to individual host for individual object?

Please help me.

Thanking you in anticipation.

Regards
Saumitra.

推荐答案

很抱歉,没有直接回答您的问题.有更好的方法.

在这种情况下,您可以做的最好的事情就是创建一个中心管理"远程对象,该对象将提供与您要实现为远程对象的所有其他对象的接口.像您可能已经做过的那样,那些嵌套对象也应该从System.MarshalByRefObject继承来实现.它们的每个类型都应实现某个接口,因此对象应由其接口表示. 管理"对象的接口应提供对嵌套对象的接口引用.

—SA
Sorry for not answering your question directly. There is a better way.

The best you can do in this case is to create a single center "managing" remote object which would provide interface to all other objects you''re trying to implement as remote objects. Those nested objects also should be implemented inheriting from System.MarshalByRefObject as you probably already do. Each of their types should implement some interface, so the object should be represented by their interfaces. The "managing" object''s interface should provide interface references to the nested objects.

—SA


感谢SAKryukov.我从你那里得到了一个概念.但是,我在主机配置文件中看到了通过以下代码执行此操作的文章:

Thanks SAKryukov. I got a concept from you. However, i have seen an article doing it by the following code in the host config file:

<wellknown mode="single call" type="namespace.class1,assembly1" objecturi="class1.uri">
<wellknown mode="single call" type="namespace.class2,assembly1" objecturi="class2.uri"></wellknown></wellknown>



我不确定这是唯一还是最简单的方法.我没有找到其他解决此问题的文章使用.Net远程处理托管多个对象.请问您提供我建议的任何文章或示例吗?

非常感谢.

Saumitra Kumar Paul



I am not sure whether it is the only or simplest way. I have not found any other article solving this problem "hosting multiple object with .Net remoting. Would you please provide me any article or example that you suggested?

Thank you very much.

Saumitra Kumar Paul


这篇关于多重远程对象问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆