关于Remoting的两个问题

时间:2015-04-06 03:28:52

标签: c# remoting

【问题1】

在远程处理的客户端激活模式下:

RemotingConfiguration.RegisterActivatedClientType(               
                typeof(ServerRemoteObject.ServerObject),
                "tcp://localhost:8080/ServiceMessage");
 ServerRemoteObject.ServerObject serverObj = new ServerRemoteObject.ServerObject();

假设“ServiceRemoteObject”是一个继承自MarshalByRefObject的类,它有一个默认的公共构造函数,它由客户端应用程序引用。

所以,如果我说:

 ServerRemoteObject.ServerObject serverObj = new ServerRemoteObject.ServerObject();

客户端应用程序如何知道是否通过远程处理创建serverObj实例,而不是通过本地“新”直接创建该实例?

【问题2】

我不想从服务器端引用ServerRemoteObject,所以我只是通过在客户端创建相同的类来欺骗服务器端:

public class ServerObject:MarshalByRefObject
    {
        public ServerObj()
        {
            throw new System.NotImplementedException();
        }

        public Person GetPersonInfo(string name,string sex,int age)
        {
            throw new System.NotImplementedException();
        }       
    }

这也很好,为什么?因为在我看来,服务器端类的名称空间......与客户端名称不同,这意味着我欺骗了服务器端。但它如何转换?

0 个答案:

没有答案
相关问题