Export (0) Print
Expand All

RemotingServices::SetObjectUriForMarshal Method

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

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

[SecurityPermissionAttribute(SecurityAction::Demand, Flags = SecurityPermissionFlag::RemotingConfiguration)]
static void SetObjectUriForMarshal(
	MarshalByRefObject^ obj, 
	String^ uri


Type: System::MarshalByRefObject

The object to set a URI for.

Type: System::String

The URI to assign to the specified object.


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


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 namespace System;
using namespace System::Runtime::Remoting;
using namespace System::Security::Permissions;

public ref class SetObjectUriForMarshalTest
   ref class TestClass: public MarshalByRefObject{};

   [SecurityPermissionAttribute(SecurityAction::Demand, Flags=SecurityPermissionFlag::RemotingConfiguration)]   
   static void Main()
      TestClass^ obj = gcnew TestClass;
      RemotingServices::SetObjectUriForMarshal( obj,  "testUri" );
      Console::WriteLine( RemotingServices::GetObjectUri( obj ) );


.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

© 2014 Microsoft