2015-12-14 2 views
0

Le client et le serveur sont sur le même ordinateur..Net distant et client verrouillé mais n'affiche aucune erreur

côté serveur, je bâtirai mon objet distant dans un thread séparé (son est pas le fil principal):

Private _remoteObject as RemoteObject 
... 

'Just one time : 
Dim tc as TcpChannel = New TcpChannel(1002) 
ChannelServices.registerChannel(tc, false) 
RemotingConfiguration.RegisterWellKnownServiceType(GetType(IRemoteObject), "RemoteServerObject", WellKnownObjectMode.SingleCall) 
RemotingServices.Marshal(_remoteObject, "RemoteServerObject") 
... 
_remoteObject = new RemoteObject() 
_remoteObject.RemoteOtherObjects.Add(New RemoteOtherObject(_property1, _property2)) 

côté client:

Private _remoteObject as Remoting.IRemoteObject 
... 
'One time 
Dim tcpChannel As New TcpChannel() 
ChannelServices.RegisterChannel(tcpChannel, false) 
Dim _remoteObject as IRemoteObject 
_remoteObject = Activator.GetObject(GetType(RemotingObject.IRemoteObject), "tcp://localhost:1002/RemoteServerObject") 
While True 
    Thread.Sleep(1000) 
    Dim remoteOtherObject as IRemoteOtherObject = _remoteObject.GetRemoteOtherObjectByName("testName") 
    For Each property2 as IProperty2 In remoteOtherObject.Properties2 
     Console.WriteLine(property2.someting) 
    Next 
End While 

Tous les sous-objets du classe RemoteObject hérite MarshalByRefObject. Le client ne voit qu'une interface de RemoteObject (DLL séparée).

Mon problème est, dans la boucle pour chaque à côté client, je n'ai pas erreur, il est juste verrouillé, ma console répond, mais rien est écrit.

Une idée de ce problème?

+0

Quelque chose d'autre pour améliorer ma question: J'ai essayé de passer par Singleton ou SingleCall, le même problème apparaît. – Thib

+0

On dirait que le serveur ne donne pas le temps au client d'obtenir l'objet. – Thib

+0

Côté client, mes objets sont bien récupérés, ils sont sous forme TransparentProxy. Il semble qu'il y ait un problème pour les transformer en vrais proxy/objets ... – Thib

Répondre

0

Le problème était un problème de conflit entre les deux invites. Celui du côté serveur utilisait le même thread UI du client, qui n'était pas actualisé.