RemotingServices.Connect メソッド

定義

既知のオブジェクトのプロキシを作成します。

オーバーロード

Connect(Type, String)

Type および URL を指定して、既知のオブジェクトのプロキシを作成します。

Connect(Type, String, Object)

Type、URL、およびチャネル固有のデータを指定して、既知のオブジェクトのプロキシを作成します。

Connect(Type, String)

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

パラメーター

classToProxy
Type

サーバー エンドにある接続する既知のオブジェクトの Type

url
String

サーバー クラスの URL。

戻り値

Object

指定した既知のオブジェクトによって提供されたエンドポイントを指す、リモート オブジェクトへのプロキシ。

属性

例外

直前の呼び出し元に、リモート処理の型とチャネルを構成するためのアクセス許可がありません。

次のコード例では、メソッドを使用して既知の Connect オブジェクトへのプロキシを作成する方法を示します。

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

注釈

返されるプロキシ オブジェクトは、指定された既知のオブジェクトによって提供されるエンドポイントを指します。 プロキシでメソッドが呼び出されるまで、ネットワーク経由でメッセージは送信されません。

適用対象

Connect(Type, String, Object)

Type、URL、およびチャネル固有のデータを指定して、既知のオブジェクトのプロキシを作成します。

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

パラメーター

classToProxy
Type

接続する既知のオブジェクトの Type

url
String

既知のオブジェクトの URL。

data
Object

チャネル固有のデータ。 null の可能性があります。

戻り値

Object

要求した既知のオブジェクトによって提供されたエンドポイントを指すプロキシ。

属性

例外

直前の呼び出し元に、リモート処理の型とチャネルを構成するためのアクセス許可がありません。

注釈

返されるプロキシ オブジェクトは、指定された既知のオブジェクトによって提供されるエンドポイントを指します。 プロキシでメソッドが呼び出されるまで、ネットワーク経由でメッセージは送信されません。

オブジェクトは data 、チャネルに情報を通信するために使用され、メソッドに IChannelSender.CreateMessageSink 渡されます。

適用対象