Langue

RemotingServices.Connect Méthode

Définition

Crée un proxy pour un objet bien connu.

Surcharges

Nom Description
Connect(Type, String)

Crée un proxy pour un objet connu, en fonction de l’URL et de l’URL Type .

Connect(Type, String, Object)

Crée un proxy pour un objet connu, en fonction des données spécifiques au canal, à l’URL et à l’URL Type.

Connect(Type, String)

Crée un proxy pour un objet connu, en fonction de l’URL et de l’URL Type .

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

Paramètres

classToProxy
Type

Objet Type connu sur le serveur à laquelle vous souhaitez vous connecter.

url
String

URL de la classe de serveur.

Retours

Proxy vers l’objet distant qui pointe vers un point de terminaison servi par l’objet bien connu spécifié.

Attributs

Exceptions

L’appelant immédiat n’est pas autorisé à configurer les types et canaux de communication à distance.

Exemples

L’exemple de code suivant montre comment utiliser la Connect méthode pour créer un proxy vers un objet bien connu.

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

Remarques

L’objet proxy retourné pointe vers un point de terminaison servi par l’objet bien connu spécifié. Aucun message n’est envoyé sur le réseau tant qu’une méthode n’est pas appelée sur le proxy.

S’applique à

Connect(Type, String, Object)

Crée un proxy pour un objet connu, en fonction des données spécifiques au canal, à l’URL et à l’URL Type.

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

Paramètres

classToProxy
Type

Objet Type connu auquel vous souhaitez vous connecter.

url
String

URL de l’objet connu.

data
Object

Données spécifiques au canal. Peut être null.

Retours

Proxy qui pointe vers un point de terminaison qui est servi par l’objet bien connu demandé.

Attributs

Exceptions

L’appelant immédiat n’est pas autorisé à configurer les types et canaux de communication à distance.

Remarques

L’objet proxy retourné pointe vers un point de terminaison servi par l’objet bien connu spécifié. Aucun message n’est envoyé sur le réseau tant qu’une méthode n’est pas appelée sur le proxy.

L’objet data est utilisé pour communiquer des informations au canal et est passé à la IChannelSender.CreateMessageSink méthode.

S’applique à