SetObjectUriForMarshal Method

RemotingServices.SetObjectUriForMarshal Method

Sets the URI for the subsequent call to the Marshal method.

Namespace: System.Runtime.Remoting
Assembly: mscorlib (in mscorlib.dll)

public static void SetObjectUriForMarshal (
	MarshalByRefObject obj,
	string uri
)
public static void SetObjectUriForMarshal (
	MarshalByRefObject obj, 
	String uri
)
public static function SetObjectUriForMarshal (
	obj : MarshalByRefObject, 
	uri : String
)

Parameters

obj

The object to set a URI for.

uri

The URI to assign to the specified object.

Exception typeCondition

RemotingException

obj is not a local object, has already been marshaled, or the current method has already been called on.

SecurityException

At least one of the callers higher in the callstack does not have permission to configure remoting types and channels.

The URI set by the current method is used when marshaling the given object.

After marshaling, the URI of the specified object is set to the string in the uri parameter appended onto the Guid of the current AppDomain.

If the current application is listening on an HTTP port, then both the string specified in the uri parameter and the uri string appended onto the Guid of the current AppDomain route to the specified object. For example, if the application is listening on HTTP port 9000, then both http://localhost:9000/objectUri, and http://localhost:9000/<appdomainguid>/objectUri route to the object specified in the obj parameter.

The following code example demonstrates how to set the URI that will be used by the Marshal method when marshaling the specified object.

using System;
using System.Runtime.Remoting;
using System.Security.Permissions;

public class SetObjectUriForMarshalTest  {

    class TestClass : MarshalByRefObject {
    }

    [SecurityPermission(SecurityAction.LinkDemand)]
    public static void Main()  {

        TestClass obj = new TestClass();    

        RemotingServices.SetObjectUriForMarshal(obj, "testUri");
        RemotingServices.Marshal(obj);

        Console.WriteLine(RemotingServices.GetObjectUri(obj));
    }
}

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2016 Microsoft