Compartir vía


RemotingServices.Connect Método

Definición

Crea un proxy para un objeto conocido.

Sobrecargas

Connect(Type, String)

Crea un proxy para un objeto conocido, con el Type y la dirección URL especificados.

Connect(Type, String, Object)

Crea un proxy para un objeto conocido, con el Type, la dirección URL y los datos de canal especificados.

Connect(Type, String)

Crea un proxy para un objeto conocido, con el Type y la dirección URL especificados.

public:
 static System::Object ^ Connect(Type ^ classToProxy, System::String ^ url);
public static object Connect (Type classToProxy, string url);
[System.Runtime.InteropServices.ComVisible(true)]
public static object Connect (Type classToProxy, string url);
[System.Runtime.InteropServices.ComVisible(true)]
[System.Security.SecurityCritical]
public static object Connect (Type classToProxy, string url);
static member Connect : Type * string -> obj
[<System.Runtime.InteropServices.ComVisible(true)>]
static member Connect : Type * string -> obj
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Security.SecurityCritical>]
static member Connect : Type * string -> obj
Public Shared Function Connect (classToProxy As Type, url As String) As Object

Parámetros

classToProxy
Type

Type de un objeto conocido situado en el extremo del servidor con el que desea establecer una conexión.

url
String

Dirección URL de la clase de servidor.

Devoluciones

Object

Proxy del objeto remoto que apunta a un extremo atendido por el objeto conocido que se ha especificado.

Atributos

Excepciones

El llamador inmediato no tiene permiso para configurar los tipos y canales de comunicación remota.

Ejemplos

En el ejemplo de código siguiente se muestra cómo usar el Connect método para crear un proxy en un objeto conocido.

Console::WriteLine( "Connecting to SampleNamespace::SampleWellKnown." );
SampleWellKnown ^ proxy = dynamic_cast<SampleWellKnown^>(RemotingServices::Connect( SampleWellKnown::typeid, const_cast<String^>(SERVER_URL) ));
Console::WriteLine( "Connected to SampleWellKnown" );

// Verifies that the Object* reference is to a transparent proxy.
if ( RemotingServices::IsTransparentProxy( proxy ) )
      Console::WriteLine( "proxy is a reference to a transparent proxy." );
else
      Console::WriteLine( "proxy is not a transparent proxy.  This is unexpected." );

// Calls a method on the server Object*.
Console::WriteLine( "proxy->Add returned {0}.", proxy->Add( 2, 3 ) );
Console.WriteLine("Connecting to SampleNamespace.SampleWellKnown.");

SampleWellKnown proxy =
   (SampleWellKnown)RemotingServices.Connect(typeof(SampleWellKnown), SERVER_URL);

Console.WriteLine("Connected to SampleWellKnown");

// Verifies that the object reference is to a transparent proxy.
if (RemotingServices.IsTransparentProxy(proxy))
    Console.WriteLine("proxy is a reference to a transparent proxy.");
else
    Console.WriteLine("proxy is not a transparent proxy.  This is unexpected.");

// Calls a method on the server object.
Console.WriteLine("proxy.Add returned {0}.", proxy.Add(2, 3));
Console.WriteLine("Connecting to SampleNamespace.SampleWellKnown.")

Dim proxy As SampleWellKnown = _
   CType(RemotingServices.Connect(GetType(SampleWellKnown), SERVER_URL), SampleWellKnown)

Console.WriteLine("Connected to SampleWellKnown")

' Verifies that the object reference is to a transparent proxy.
If RemotingServices.IsTransparentProxy(proxy) Then
   Console.WriteLine("proxy is a reference to a transparent proxy.")
Else
   Console.WriteLine("proxy is not a transparent proxy.  This is unexpected.")
End If

' Calls a method on the server object.
Console.WriteLine("proxy.Add returned {0}.", proxy.Add(2, 3))

Comentarios

El objeto proxy devuelto apunta a un punto de conexión servido por el objeto conocido especificado. No se envía ningún mensaje a través de la red hasta que se llama a un método en el proxy.

Se aplica a

Connect(Type, String, Object)

Crea un proxy para un objeto conocido, con el Type, la dirección URL y los datos de canal especificados.

public:
 static System::Object ^ Connect(Type ^ classToProxy, System::String ^ url, System::Object ^ data);
public static object Connect (Type classToProxy, string url, object data);
[System.Runtime.InteropServices.ComVisible(true)]
public static object Connect (Type classToProxy, string url, object data);
[System.Runtime.InteropServices.ComVisible(true)]
[System.Security.SecurityCritical]
public static object Connect (Type classToProxy, string url, object data);
static member Connect : Type * string * obj -> obj
[<System.Runtime.InteropServices.ComVisible(true)>]
static member Connect : Type * string * obj -> obj
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Security.SecurityCritical>]
static member Connect : Type * string * obj -> obj
Public Shared Function Connect (classToProxy As Type, url As String, data As Object) As Object

Parámetros

classToProxy
Type

Type del objeto conocido con el que se desea establecer una conexión.

url
String

URL del objeto conocido.

data
Object

Datos específicos del canal. Puede ser null.

Devoluciones

Object

Proxy que apunta a un extremo atendido por el objeto conocido que se ha solicitado.

Atributos

Excepciones

El llamador inmediato no tiene permiso para configurar los tipos y canales de comunicación remota.

Comentarios

El objeto proxy devuelto apunta a un punto de conexión servido por el objeto conocido especificado. No se envía ningún mensaje a través de la red hasta que se llama a un método en el proxy.

El data objeto se usa para comunicar información al canal y se pasa al IChannelSender.CreateMessageSink método .

Se aplica a