Ver Mensaje Individual
  #6 (permalink)  
Antiguo 04/06/2004, 08:00
rcorichard
 
Fecha de Ingreso: mayo-2004
Ubicación: Guadalajara, Jalisco
Mensajes: 47
Antigüedad: 20 años
Puntos: 0
Mensaje

Pues hay muchas formas de utilizar el .Net Remoting, pero básicamente una de las mas simples es tener 3 aplicaciones, Un servidor (quien albergará los objetos), un cliente (quien consumirá los objetos que tiene el servidor) y Una libreria de clases (donde tendrás los objetos que utilizaran las dos aplicaciones anteriores).

Los objetos que quieres publicar como remotos remotos deben heredar de la clase MarshalByRefObject

Cita:
Public Class MyRemoteObject
Inherits MarshalByRefObject

'Propiedades y Metodos
....

End Class

En el servidor es necesario agregar una referencia a la DLL que contiene a MyRemoteOjbect, registrar un canal (ya sea http o tcp) con un puerto libre por el cual escuchará las peticiones de la aplicación servidor y luego publicar el objeto remoto:

Cita:
Imports System
Imports System.Runtime.Remoting
Imports System.Runtime.Remoting.Channels
Imports System.Runtime.Remoting.Channels.Http

Public Sub Main()

Dim channel As New HttpChannel(8080)
ChannelServices.RegisterChannel(channel)

RemotingConfiguration.RegisterWellKnownServiceType _
(GetType(MyRemoteObject), "MyRemoteObject.Rem", WellKnownObjectMode.Singleton)

End Sub
Y en el cliente también agregas una referencia a la DLL que contiene MyRemoteObject, registras un canal y obtenienes una referencia al objeto que se encuentra en la aplicación:

Cita:

Public Sub Main()
Dim channel As New HttpChannel(0)
ChannelServices.RegisterChannel(channel)

RemotingConfiguration.RegisterWellKnownClientType _
(GetType(MyRemoteObject), "tcp://localhost:8080/MyRemoteObject.rem")

'Ahora cualquier referencia a MyRemoteObject, en realidad hará referencia
'al objeto que se encuentra en la aplicación servidor.
Dim RemoteObject as MyRemoteObject=new MyRemoteObject()

End Sub
Nota: Este es solo una de las formas en que puedes utilizar .Net Remoting.
__________________
Si puedes pensarlo, puedes hacerlo.