关于remoting的问题

panwen516 2009-09-01 11:54:49
remoting有SingleCall和客户端模式操作服务与客户端,
但SingleCall与客户端激活模式都是创建为每个客户段创建一个新对象,我就想问了,

公共模块:
public class ServerObject:MarshalByRefObject
{
publie string Name
{
get{...}
set{....}
}
public ServerObject()
{

}

public Person GetPersonInfo(string name,string sex,int age)
{
Person person = new Person();
person.Name = name;
person.Sex = sex;
person.Age = age;
return person;
}
}

服务器端:
(singlecall模式)
TcpChannel channel = new TcpChannel(8080);
ChannelServices.RegisterChannel(channel);
RemotingConfiguration.RegisterWellKnownServiceType(
typeof(ServerRemoteObject.ServerObject),
"ServiceMessage",WellKnownObjectMode.SingleCall);

(客户端激活模式)
客户端:
TcpChannel channel = new TcpChannel();
ChannelServices.RegisterChannel(channel);
(1) WellKnown激活模式
ServerRemoteObject.ServerObject serverObj = (ServerRemoteObject.ServerObject)Activator.GetObject(
typeof(ServerRemoteObject.ServerObject), "tcp://localhost:8080/ServiceMessage");
(2) 客户端激活模式
RemotingConfiguration.RegisterActivatedClientType(
typeof(ServerRemoteObject.ServerObject),
"tcp://localhost:8080/ServiceMessage");
ServerRemoteObject.ServerObject serverObj = new ServerRemoteObject.ServerObject();

我不明白的地方是,客户端怎么获取到服务器的状态对象的呢?
比如:服务器端ServerObject对象的Name属性我给它赋值为"Tom",那客户端这边也能获取到"Tom"这个值吗?
初学者不要见笑

...全文
49 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧