Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1498 connectés 

  FORUM HardWare.fr
  Programmation
  C#/.NET managed

  probléme de Remoting

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

probléme de Remoting

n°1947838
man_u
Posté le 07-12-2009 à 11:30:38  profilanswer
 

Bonjour tous le monde,
j'essaye de faire un simple programme pour comprendre le fonctionnement de Remoting , mais il ne marche pas pourtant il est trés simple.
le probléme c'est qu'il ne reconnais pas la classe : TcpChannel ()  
voila le code:
 
l'Objet Distant:

Code :
  1. using System;
  2. using System.Runtime.Remoting;
  3. using System.Runtime.Remoting.Channels;
  4. using System.Runtime.Remoting.Channels.Tcp;
  5. namespace enaxos.Remoting
  6. {
  7.     public class ObjetRemotable : MarshalByRefObject
  8.     {
  9.         //////////////////////////////////////////////////////////////////////////////
  10.         ///constructor
  11.         public ObjetRemotable()
  12.         {
  13.             Console.WriteLine("Remote object activated" );
  14.         }
  15.         //////////////////////////////////////////////////////////////////////////////
  16.         ///return message reply
  17.         public String Salut()
  18.         {
  19.             return "Server : Yeah! I'm here";
  20.         }
  21.     }
  22. }


 
 
Serveur:

Code :
  1. using System;
  2. using System.Runtime.Remoting;
  3. using System.Runtime.Remoting.Channels;
  4. using System.Runtime.Remoting.Channels.Tcp;
  5. namespace enaxos.Remoting
  6. {
  7.     public class ServerTest
  8.     {
  9.         public static int Main(string[] args)
  10.         {
  11.             //select channel to communicate
  12.             TcpChannel channel = new TcpChannel(8080);
  13.             ChannelServices.RegisterChannel(channel);    //register channel
  14.             //register remote object
  15.             RemotingConfiguration.RegisterWellKnownServiceType(
  16.                 typeof(ObjetRemotable),"bonjour",WellKnownObjectMode.SingleCall);
  17.             //inform console
  18.             Console.WriteLine("Server Activated..." );
  19.             Console.ReadLine();
  20.             return 0;
  21.         }
  22.     }
  23. }


 
Client :

Code :
  1. using System;
  2. using System.Runtime.Remoting;
  3. using System.Runtime.Remoting.Channels;
  4. using System.Runtime.Remoting.Channels.Tcp;
  5. namespace enaxos.Remoting
  6. {
  7.     public class ClientSimple
  8.     {
  9.         public static int Main(string[] args)
  10.         {
  11.             //select channel to communicate with server
  12.             TcpChannel channel = new TcpChannel();
  13.             ChannelServices.RegisterChannel(channel);
  14.             ObjetRemotable obj = (ObjetRemotable)Activator.GetObject(
  15.                 typeof(enaxos.Remoting.ObjetRemotable),
  16.                 "tcp://localhost:8080/Bonjour" );
  17.             if (obj.Equals(null))
  18.                 Console.WriteLine("Serveur Non Trouvé" );
  19.             else
  20.                 Console.WriteLine(obj.Salut());
  21.             return 0;
  22.         }
  23.     }
  24. }


Merci d'avance


Message édité par man_u le 07-12-2009 à 11:33:00
mood
Publicité
Posté le 07-12-2009 à 11:30:38  profilanswer
 

n°1947841
Harkonnen
Modérateur
Un modo pour les bannir tous
Posté le 07-12-2009 à 11:41:17  profilanswer
 

t'as bien inclus la référence à System.Runtime.Remoting.dll dans ton projet ?  
(je parle bien de la référence, pas du namespace que tu as correctement inclus via ton using)


---------------
J'ai un string dans l'array (Paris Hilton)
n°1948048
man_u
Posté le 07-12-2009 à 17:03:11  profilanswer
 

ouééééé c'étais sa le probléme . merciii Harkonnen


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  C#/.NET managed

  probléme de Remoting

 

Sujets relatifs
Problème fonction include()[MCD] problème de conception : livraisons et colis
Problème 1004Encore un problème de doublons
Problème de caractères accentués sur Windows Vista en consoleProblème d'utilisation du if
[Jquery] - Problème de sélecteurProblème de lancement de batch
Probleme, fonction page précédente / suivante[Remoting] probleme avec le remoting
Plus de sujets relatifs à : probléme de Remoting


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR