RemotingServices.Connect Methode

Definition

Erstellt einen Proxy für ein bekanntes Objekt.

Überlädt

Name Beschreibung
Connect(Type, String)

Erstellt einen Proxy für ein bekanntes Objekt unter Angabe der Type URL.

Connect(Type, String, Object)

Erstellt einen Proxy für ein bekanntes Objekt, wobei die TypeURL und kanalspezifischen Daten angegeben sind.

Connect(Type, String)

Erstellt einen Proxy für ein bekanntes Objekt unter Angabe der Type 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

Parameter

classToProxy
Type

Das Type von einem bekannten Objekt auf dem Serverende, mit dem Sie eine Verbindung herstellen möchten.

url
String

Die URL der Serverklasse.

Gibt zurück

Ein Proxy für das Remoteobjekt, das auf einen Endpunkt verweist, der vom angegebenen bekannten Objekt bereitgestellt wird.

Attribute

Ausnahmen

Der direkte Aufrufer verfügt nicht über die Berechtigung zum Konfigurieren von Remotingtypen und Kanälen.

Beispiele

Im folgenden Codebeispiel wird die Verwendung der Connect Methode zum Erstellen eines Proxys für ein bekanntes Objekt veranschaulicht.

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

Hinweise

Das zurückgegebene Proxyobjekt verweist auf einen Endpunkt, der vom angegebenen bekannten Objekt bereitgestellt wird. Es werden keine Nachrichten über das Netzwerk gesendet, bis eine Methode für den Proxy aufgerufen wird.

Gilt für:

Connect(Type, String, Object)

Erstellt einen Proxy für ein bekanntes Objekt, wobei die TypeURL und kanalspezifischen Daten angegeben sind.

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

Parameter

classToProxy
Type

Das Type bekannte Objekt, mit dem Sie eine Verbindung herstellen möchten.

url
String

Die URL des bekannten Objekts.

data
Object

Kanalspezifische Daten. Kann null sein.

Gibt zurück

Ein Proxy, der auf einen Endpunkt verweist, der vom angeforderten bekannten Objekt bereitgestellt wird.

Attribute

Ausnahmen

Der direkte Aufrufer verfügt nicht über die Berechtigung zum Konfigurieren von Remotingtypen und Kanälen.

Hinweise

Das zurückgegebene Proxyobjekt verweist auf einen Endpunkt, der vom angegebenen bekannten Objekt bereitgestellt wird. Es werden keine Nachrichten über das Netzwerk gesendet, bis eine Methode für den Proxy aufgerufen wird.

Das data Objekt wird verwendet, um Informationen an den Kanal zu übermitteln und an die IChannelSender.CreateMessageSink Methode zu übergeben.

Gilt für: