RemotingServices.Marshal Method
Converts the given MarshalByRefObject into an instance of the ObjRef class, which can be serialized for transmission between application domains and over a network.
Overload List
Takes a MarshalByRefObject, registers it with the remoting infrastructure, and converts it into an instance of the ObjRef class.
[Visual Basic] Overloads Public Shared Function Marshal(MarshalByRefObject) As ObjRef
[C#] public static ObjRef Marshal(MarshalByRefObject);
[C++] public: static ObjRef* Marshal(MarshalByRefObject*);
[JScript] public static function Marshal(MarshalByRefObject) : ObjRef;
Converts the given MarshalByRefObject into an instance of the ObjRef class with the specified URI.
[Visual Basic] Overloads Public Shared Function Marshal(MarshalByRefObject, String) As ObjRef
[C#] public static ObjRef Marshal(MarshalByRefObject, string);
[C++] public: static ObjRef* Marshal(MarshalByRefObject*, String*);
[JScript] public static function Marshal(MarshalByRefObject, String) : ObjRef;
Takes a MarshalByRefObject and converts it into an instance of the ObjRef class with the specified URI, and the provided Type.
[Visual Basic] Overloads Public Shared Function Marshal(MarshalByRefObject, String, Type) As ObjRef
[C#] public static ObjRef Marshal(MarshalByRefObject, string, Type);
[C++] public: static ObjRef* Marshal(MarshalByRefObject*, String*, Type*);
[JScript] public static function Marshal(MarshalByRefObject, String, Type) : ObjRef;
Example
[Visual Basic, C#, C++] The following example demonstrates how to use the current Marshal method to marshal a specified object.
[Visual Basic, C#, C++] Note This example shows how to use one of the overloaded versions of Marshal. For other examples that might be available, see the individual overload topics.
[Visual Basic] Dim channel As New TcpChannel(9000) ChannelServices.RegisterChannel(channel) Dim objectWellKnown As New SampleWellKnown() ' After the channel is registered, the object needs to be registered ' with the remoting infrastructure. So, Marshal is called. Dim objrefWellKnown As ObjRef = RemotingServices.Marshal(objectWellKnown, "objectWellKnownUri") Console.WriteLine("An instance of SampleWellKnown type is published at {0}.", objrefWellKnown.URI) Console.WriteLine("Press enter to unregister SampleWellKnown, so that it is no longer available on this channel.") Console.ReadLine() RemotingServices.Disconnect(objectWellKnown) Console.WriteLine("Press enter to end the server process.") Console.ReadLine() [C#] TcpChannel channel = new TcpChannel(9000); ChannelServices.RegisterChannel(channel); SampleWellKnown objectWellKnown = new SampleWellKnown(); // After the channel is registered, the object needs to be registered // with the remoting infrastructure. So, Marshal is called. ObjRef objrefWellKnown = RemotingServices.Marshal(objectWellKnown, "objectWellKnownUri"); Console.WriteLine("An instance of SampleWellKnown type is published at {0}.", objrefWellKnown.URI); Console.WriteLine("Press enter to unregister SampleWellKnown, so that it is no longer available on this channel."); Console.ReadLine(); RemotingServices.Disconnect(objectWellKnown); Console.WriteLine("Press enter to end the server process."); Console.ReadLine(); [C++] TcpChannel* channel = new TcpChannel(9000); ChannelServices::RegisterChannel(channel); SampleWellKnown* objectWellKnown = new SampleWellKnown(); // After the channel is registered, the Object* needs to be registered // with the remoting infrastructure. So, Marshal is called. ObjRef* objrefWellKnown = RemotingServices::Marshal(objectWellKnown, S"objectWellKnownUri"); Console::WriteLine(S"An instance of SampleWellKnown type is published at {0}.", objrefWellKnown->URI); Console::WriteLine(S"Press enter to unregister SampleWellKnown, so that it is no longer available on this channel."); Console::ReadLine(); RemotingServices::Disconnect(objectWellKnown); Console::WriteLine(S"Press enter to end the server process."); Console::ReadLine();
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
See Also
RemotingServices Class | RemotingServices Members | System.Runtime.Remoting Namespace