服務器:屬性的遠程處理
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