Hola a todos!!!
estoy creando un cliente servidor remting y estoy teniendo problemas ya
que, tengo una solución con tres proyectos (el cliente, el servidor y el
objeto remoto)
Mi cliente es:
using System;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using Remoto;
namespace Remoto
{
public class ValidaClient
{
[STAThread]
public static void Main()
{
ChannelServices.RegisterChannel (new TcpClientChannel());
Validador val = (Validador) Activator.GetObject
(typeof(Validador),"
tcp://localhost:4242/Valida");
System.Console.WriteLine (val.Valida());
}
}
}
El servidor es:
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
namespace Remoto
{
public class ValidaServer
{
[STAThread]
public static void Main ()
{
// instantiate the channel object
TcpServerChannel tc = new TcpServerChannel (4242);
ChannelServices.RegisterChannel (tc);
RemotingConfiguration.RegisterWellKnownServiceType (typeof(Validador),
"Valida",WellKnownObjectMode.SingleCall);
System.Console.WriteLine ("Servidor arrancado, press Enter.");
System.Console.ReadLine();
}
}
}
Y el objeto remoto es;
using System;
namespace Remoto
{
public class Validador: MarshalByRefObject
{
public Validador()
{
System.Console.WriteLine ("constructor de Validador.");
}
public string Valida()
{
System.Console.WriteLine ("Metodo Valida()");
return "Validado realizado";
}
}
}
y la excepcion que se genera es:
Información adicional: No se ha podido establecer conexión ya que el
equipo de destino ha denegado activamente dicha conexión
en la línea del cliente: System.Console.WriteLine (val.Valida());
¿Sabe alguien por que se produce y cual podría ser la solución?
Muchas gracias.
*** Sent via Developersdex
http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Leer las respuestas