Språk

RemotingServices.Connect Metod

Definition

Skapar en proxy för ett välkänt objekt.

Överlagringar

Name Description
Connect(Type, String)

Skapar en proxy för ett välkänt objekt med tanke på Type url:en och.

Connect(Type, String, Object)

Skapar en proxy för ett välkänt objekt med tanke på Type, URL och kanalspecifika data.

Connect(Type, String)

Skapar en proxy för ett välkänt objekt med tanke på Type url:en och.

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

Parametrar

classToProxy
Type

För Type ett välkänt objekt på serverdelen som du vill ansluta till.

url
String

URL:en för serverklassen.

Returer

En proxy till fjärrobjektet som pekar på en slutpunkt som hanteras av det angivna välkända objektet.

Attribut

Undantag

Den omedelbara anroparen har inte behörighet att konfigurera fjärrkommunikationstyper och kanaler.

Exempel

Följande kodexempel visar hur du använder Connect metoden för att skapa en proxy till ett välkänt objekt.

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

Kommentarer

Det returnerade proxyobjektet pekar på en slutpunkt som hanteras av det angivna välkända objektet. Inga meddelanden skickas via nätverket förrän en metod anropas på proxyn.

Gäller för

Connect(Type, String, Object)

Skapar en proxy för ett välkänt objekt med tanke på Type, URL och kanalspecifika 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

Parametrar

classToProxy
Type

Det Type välkända objekt som du vill ansluta till.

url
String

URL:en för det välkända objektet.

data
Object

Kanalspecifika data. Kan vara null.

Returer

En proxy som pekar på en slutpunkt som hanteras av det begärda välkända objektet.

Attribut

Undantag

Den omedelbara anroparen har inte behörighet att konfigurera fjärrkommunikationstyper och kanaler.

Kommentarer

Det returnerade proxyobjektet pekar på en slutpunkt som hanteras av det angivna välkända objektet. Inga meddelanden skickas via nätverket förrän en metod anropas på proxyn.

Objektet data används för att kommunicera information till kanalen och skickas IChannelSender.CreateMessageSink till metoden.

Gäller för