Connect Method (Type, String)
Collapse the table of content
Expand the table of content

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)

public static object Connect(
	Type classToProxy,
	string url


Type: System.Type

The Type of a well-known object on the server end to which you want to connect.

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.

Exception Condition

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


for configuration of the remoting infrastructure. Demand value: SecurityAction.LinkDemand; Permission value: SecurityPermissionFlag.RemotingConfiguration

.NET Framework
Available since 1.1
Return to top
© 2015 Microsoft