RemotingServices.Connect Método

Definição

Cria um proxy para um objeto conhecido.Creates a proxy for a well-known object.

Sobrecargas

Connect(Type, String)

Cria um proxy para um objeto conhecido, dados o Type e a URL.Creates a proxy for a well-known object, given the Type and URL.

Connect(Type, String, Object)

Cria um proxy para um objeto conhecido, dados o Type, a URL e os dados específicos do canal.Creates a proxy for a well-known object, given the Type, URL, and channel-specific data.

Connect(Type, String)

Cria um proxy para um objeto conhecido, dados o Type e a URL.Creates a proxy for a well-known object, given the Type and URL.

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

O Type de um objeto conhecido na extremidade do servidor ao qual você deseja se conectar.The Type of a well-known object on the server end to which you want to connect.

url
String

A URL da classe de servidor.The URL of the server class.

Retornos

Object

Um proxy para o objeto remoto que aponta para um ponto de extremidade servido pelo objeto conhecido especificado.A proxy to the remote object that points to an endpoint served by the specified well-known object.

Atributos

Exceções

O chamador imediato não tem permissão para configurar canais e tipos de comunicação remota.The immediate caller does not have permission to configure remoting types and channels.

Exemplos

O exemplo de código a seguir demonstra como usar o Connect método para criar um proxy para um objeto bem conhecido.The following code example demonstrates how to use the Connect method to create a proxy to a well-known object.

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))

Comentários

O objeto proxy retornado aponta para um ponto de extremidade servido pelo objeto conhecido especificado.The returned proxy object points to an endpoint served by the specified well-known object. Nenhuma mensagem é enviada pela rede até que um método seja chamado no proxy.No messages are sent over the network until a method is called on the proxy.

Aplica-se a

Connect(Type, String, Object)

Cria um proxy para um objeto conhecido, dados o Type, a URL e os dados específicos do canal.Creates a proxy for a well-known object, given the Type, URL, and channel-specific data.

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

O Type do objeto conhecido ao qual você deseja se conectar.The Type of the well-known object to which you want to connect.

url
String

A URL do objeto conhecido.The URL of the well-known object.

data
Object

Dados específicos do canal.Channel specific data. Pode ser null.Can be null.

Retornos

Object

Um proxy que aponta para um ponto de extremidade servido pelo objeto conhecido solicitado.A proxy that points to an endpoint that is served by the requested well-known object.

Atributos

Exceções

O chamador imediato não tem permissão para configurar canais e tipos de comunicação remota.The immediate caller does not have permission to configure remoting types and channels.

Comentários

O objeto proxy retornado aponta para um ponto de extremidade servido pelo objeto conhecido especificado.The returned proxy object points to an endpoint served by the specified well-known object. Nenhuma mensagem é enviada pela rede até que um método seja chamado no proxy.No messages are sent over the network until a method is called on the proxy.

O data objeto é usado para comunicar informações para o canal e é passado para o IChannelSender.CreateMessageSink método.The data object is used to communicate information to the channel, and is passed to the IChannelSender.CreateMessageSink method.

Aplica-se a