RemotingServices.Connect Método
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Cria um proxy para um objeto bem conhecido.
Sobrecargas
| Name | Description |
|---|---|
| Connect(Type, String) |
Cria um proxy para um objeto bem conhecido, dado o Type e URL. |
| Connect(Type, String, Object) |
Cria um proxy para um objeto bem conhecido, dado o Type, URL e dados específicos do canal. |
Connect(Type, String)
Cria um proxy para um objeto bem conhecido, dado o Type e 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
- url
- String
A URL da classe servidor.
Devoluções
Um proxy para o objeto remoto que aponta para um endpoint servido pelo objeto bem conhecido especificado.
- Atributos
Exceções
O chamador imediato não tem permissão para configurar tipos e canais remotos.
Exemplos
O exemplo de código seguinte demonstra como usar o Connect método para criar um proxy para um objeto bem conhecido.
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))
Observações
O objeto proxy devolvido aponta para um ponto final servido pelo objeto bem conhecido especificado. Nenhuma mensagem é enviada pela rede até que um método seja chamado no proxy.
Aplica-se a
Connect(Type, String, Object)
Cria um proxy para um objeto bem conhecido, dado o Type, URL e dados específicos do 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
- url
- String
A URL do objeto bem conhecido.
- data
- Object
Dados específicos do canal. Pode ser null.
Devoluções
Um proxy que aponta para um endpoint servido pelo objeto bem conhecido solicitado.
- Atributos
Exceções
O chamador imediato não tem permissão para configurar tipos e canais remotos.
Observações
O objeto proxy devolvido aponta para um ponto final servido pelo objeto bem conhecido especificado. Nenhuma mensagem é enviada pela rede até que um método seja chamado no proxy.
O data objeto é usado para comunicar informação ao canal e é passado para o IChannelSender.CreateMessageSink método.