【发布时间】:2010-05-11 10:42:57
【问题描述】:
服务器:
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;
}
}
连接正常,8080端口打开,客户端remoteHost不为空,而是remoteHost.Name == ""
为什么?
【问题讨论】:
标签: c# .net properties remoting