Language

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。

返品

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

属性

例外

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

例

次のコード例では、 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 の可能性があります。

返品

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

属性

例外

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

注釈

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

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

適用対象