RemotingServices.Connect Método

Definición

Crea un proxy para un objeto conocido.

Sobrecargas

Nombre Description
Connect(Type, String)

Crea un proxy para un objeto conocido, dada la dirección Type URL y .

Connect(Type, String, Object)

Crea un proxy para un objeto conocido, dada la Typedirección URL y los datos específicos del canal.

Connect(Type, String)

Crea un proxy para un objeto conocido, dada la dirección Type URL y .

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

de Type un objeto conocido en el extremo del servidor al que desea conectarse.

url
String

Dirección URL de la clase de servidor.

Devoluciones

Proxy al objeto remoto que apunta a un punto de conexión servido por el objeto conocido especificado.

Atributos

Excepciones

El llamador inmediato no tiene permiso para configurar tipos y canales remotos.

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, dada la Typedirección URL y los datos específicos del canal.

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 al que desea conectarse.

url
String

Dirección URL del objeto conocido.

data
Object

Datos específicos del canal. Puede ser null.

Devoluciones

Proxy que apunta a un punto de conexión que sirve el objeto conocido solicitado.

Atributos

Excepciones

El llamador inmediato no tiene permiso para configurar tipos y canales remotos.

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