System.Runtime.Remoting.RemotingServices.Marshal Method

Takes a MarshalByRefObject, registers it with the remoting infrastructure, and converts it into an instance of the System.Runtime.Remoting.ObjRef class.


public static ObjRef Marshal (MarshalByRefObject Obj)


The object to convert.


An instance of the System.Runtime.Remoting.ObjRef class that represents the object specified in the Obj parameter.


A System.Runtime.Remoting.ObjRef is a serializable representation of an object used to transfer an object reference across an application domain boundary. Creating a System.Runtime.Remoting.ObjRef for an object is known as marshaling. The System.Runtime.Remoting.ObjRef can be transferred through a channel into another application domain (possibly on another process or computer). Once in the other application domain, the System.Runtime.Remoting.ObjRef must be parsed to create a proxy for the object, generally connected to the real object. This operation is known as unmarshaling.

A System.Runtime.Remoting.ObjRef contains information that describes the Type and class of the object being marshaled, a URI that uniquely identifies the specific object instance, and communication related information about how to reach the remoting subdivision where the object is located.

During marshaling, the context from the current thread is used, not the context that was active when the object was created. If a URI was not explicitly set by the RemotingServices.SetObjectUriForMarshal(MarshalByRefObject, string) method, it is automatically generated by the remoting identity infrastructure.

You cannot associate a URI with a proxy for one of two reasons: either the URI was generated at the server side for the object it represents, or the object is well known, in which case the URI is known. For this reason, if the Obj parameter is a proxy, an exception will be thrown. For custom proxies this restriction is relaxed because the transparent proxy is treated as the server object.


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