服务器:属性的远程处理
Host h = new Host();
h.Name = "JARR!!";
TcpChannel channel = new TcpChannel(8080);
ChannelServices.RegisterChannel(channel);
RemotingConfiguration.RegisterWellKnownServiceType(typeof(Host), "Server",
WellKnownObjectMode.Singleton);
客户:
TcpChannel chan = new TcpChannel();
ChannelServices.RegisterChannel(chan);
remoteHost = (Host)Activator.GetObject(typeof(Host),
"tcp://127.0.0.1:8080/Server");
类:
[Serializable]
public class Host: MarshalByRefObject
{
public string Name{get; set;}
public Host(){}
public Host(string n)
{
Name = n;
}
public override string ToString()
{
return Name;
}
}
连接OK,8080口岸开通后,客户端侧远程主机不为空,但REMOTEHOST .Name ==“”
为什么?
插入RemotingServices.Marshal(H, “服务器” );注册知名服务后。没有任何变化 – 2010-05-11 13:06:52
对不起,所有作品都是正确的。非常感谢 – 2010-05-11 13:09:16