Serveur:Biens immobiliers à Remoting
Host h = new Host();
h.Name = "JARR!!";
TcpChannel channel = new TcpChannel(8080);
ChannelServices.RegisterChannel(channel);
RemotingConfiguration.RegisterWellKnownServiceType(typeof(Host), "Server",
WellKnownObjectMode.Singleton);
Client:
TcpChannel chan = new TcpChannel();
ChannelServices.RegisterChannel(chan);
remoteHost = (Host)Activator.GetObject(typeof(Host),
"tcp://127.0.0.1:8080/Server");
Classe:
[Serializable]
public class Host: MarshalByRefObject
{
public string Name{get; set;}
public Host(){}
public Host(string n)
{
Name = n;
}
public override string ToString()
{
return Name;
}
}
Connexion OK, 8080 le port ouvert, sur le côté client remoteHost est non nul, mais remoteHost .Name == ""
Pourquoi?
insérer RemotingServices.Marshal (h, "Serveur") après avoir enregistré un service bien connu. Rien ne change –
Je suis désolé tout fonctionne correctement. Merci beaucoup –