Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

RemotingServices.Connect Method (Type, String)

Creates a proxy for a well-known object, given the Type and URL.

Namespace:  System.Runtime.Remoting
Assembly:  mscorlib (in mscorlib.dll)
[ComVisibleAttribute(true)]
public static Object Connect(
	Type classToProxy,
	string url
)

Parameters

classToProxy
Type: System.Type
The Type of a well-known object on the server end to which you want to connect.
url
Type: System.String
The URL of the server class.

Return Value

Type: System.Object
A proxy to the remote object that points to an endpoint served by the specified well-known object.
ExceptionCondition
SecurityException

The immediate caller does not have permission to configure remoting types and channels.

The returned proxy object points to an endpoint served by the specified well-known object. No messages are sent over the network until a method is called on the proxy.

The following code example demonstrates how to use the Connect method to create a proxy to a well-known object.


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


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.