Export (0) Print
Expand All

RemotingServices.SetObjectUriForMarshal Method

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

[Visual Basic]
Public Shared Sub SetObjectUriForMarshal( _
   ByVal obj As MarshalByRefObject, _
   ByVal uri As String _
public static void SetObjectUriForMarshal(
 MarshalByRefObject obj,
 string uri
public: static void SetObjectUriForMarshal(
 MarshalByRefObject* obj,
 String* uri
public static function SetObjectUriForMarshal(
   obj : MarshalByRefObject,
 uri : String


The object to set a URI for.
The URI to assign to the specified object.


Exception Type Condition
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.

Note   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.
Note   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.


[Visual Basic, C#, C++] The following example demonstrates how to set the URI that will be used by the Marshal method when marshaling the specified object.

[Visual Basic] 
Imports System
Imports System.Runtime.Remoting

Public Class SetObjectUriForMarshalTest
    Class TestClass
        Inherits MarshalByRefObject
    End Class

    Public Shared Sub Main()
        Dim obj As TestClass = New TestClass()

        RemotingServices.SetObjectUriForMarshal(obj, "testUri")

    End Sub

End Class

using System;
using System.Runtime.Remoting;

public class SetObjectUriForMarshalTest  {

    class TestClass : MarshalByRefObject {

    public static void Main()  {

        TestClass obj = new TestClass();    

        RemotingServices.SetObjectUriForMarshal(obj, "testUri");


#using <mscorlib.dll>

using namespace System;
using namespace System::Runtime::Remoting;

public __gc class SetObjectUriForMarshalTest
    __gc class TestClass : public MarshalByRefObject

        static void Main() 
            TestClass * obj = new TestClass();    

            RemotingServices::SetObjectUriForMarshal(obj, "testUri");


[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

.NET Framework Security: 

See Also

RemotingServices Class | RemotingServices Members | System.Runtime.Remoting Namespace | Uri | Guid

© 2015 Microsoft