RemotingServices.Connect Méthode
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Crée un proxy pour un objet connu.
Surcharges
Connect(Type, String) |
Crée un proxy pour un objet connu, en fonction du Type et de l'URL. |
Connect(Type, String, Object) |
Crée un proxy pour un objet connu, en fonction du Type, de l'URL et de données spécifiques de canal. |
Connect(Type, String)
Crée un proxy pour un objet connu, en fonction du Type et de l'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
Paramètres
- url
- String
URL de la classe de serveur.
Retours
Proxy pour l'objet distant qui pointe vers un point de terminaison pris en charge par l'objet connu spécifié.
- Attributs
Exceptions
L'appelant immédiat n'a pas l'autorisation requise pour configurer les canaux et les types 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 du Type, de l'URL et de données spécifiques de 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
Paramètres
- 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 pris en charge par l'objet connu demandé.
- Attributs
Exceptions
L'appelant immédiat n'a pas l'autorisation requise pour configurer les canaux et les types 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.