RemotingServices.Connect Metoda

Definicja

Tworzy serwer proxy dla dobrze znanego obiektu.

Przeciążenia

Connect(Type, String)

Tworzy serwer proxy dla dobrze znanego obiektu, biorąc pod Type uwagę adres URL i .

Connect(Type, String, Object)

Tworzy serwer proxy dla dobrze znanego obiektu, biorąc pod uwagę Typeadres URL i dane specyficzne dla kanału.

Connect(Type, String)

Tworzy serwer proxy dla dobrze znanego obiektu, biorąc pod Type uwagę adres URL i .

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

Parametry

classToProxy
Type

Obiekt Type dobrze znanego na końcu serwera, z którym chcesz nawiązać połączenie.

url
String

Adres URL klasy serwera.

Zwraca

Object

Serwer proxy do obiektu zdalnego, który wskazuje punkt końcowy obsługiwany przez określony dobrze znany obiekt.

Atrybuty

Wyjątki

Bezpośredni obiekt wywołujący nie ma uprawnień do konfigurowania typów i kanałów komunikacji telefonicznej.

Przykłady

W poniższym przykładzie kodu pokazano, jak za pomocą Connect metody utworzyć serwer proxy dla dobrze znanego obiektu.

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

Uwagi

Zwrócony obiekt serwera proxy wskazuje punkt końcowy obsługiwany przez określony dobrze znany obiekt. Żadne komunikaty nie są wysyłane przez sieć do momentu wywołania metody na serwerze proxy.

Dotyczy

Connect(Type, String, Object)

Tworzy serwer proxy dla dobrze znanego obiektu, biorąc pod uwagę Typeadres URL i dane specyficzne dla kanału.

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

Parametry

classToProxy
Type

Obiekt Type dobrze znanego obiektu, z którym chcesz nawiązać połączenie.

url
String

Adres URL dobrze znanego obiektu.

data
Object

Dane specyficzne dla kanału. Może to być null.

Zwraca

Object

Serwer proxy wskazujący punkt końcowy obsługiwany przez żądany dobrze znany obiekt.

Atrybuty

Wyjątki

Bezpośredni obiekt wywołujący nie ma uprawnień do konfigurowania typów i kanałów komunikacji telefonicznej.

Uwagi

Zwrócony obiekt serwera proxy wskazuje punkt końcowy obsługiwany przez określony dobrze znany obiekt. Żadne komunikaty nie są wysyłane przez sieć do momentu wywołania metody na serwerze proxy.

Obiekt data służy do przekazywania informacji do kanału i jest przekazywany do IChannelSender.CreateMessageSink metody .

Dotyczy