Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2005
Visual Studio
.NET Remoting
 How to: Build a Remotable Type
This page is specific to
Microsoft Visual Studio 2005/.NET Framework 2.0

Other versions are also available for the following:
.NET Framework Developer's Guide 
How to: Build a Remotable Type 

To enable objects in other application domains to use an instance of your class, your class must inherit from MarshalByRefObject. The following procedure describes how to create a basic object that can be created and invoked from objects executing in another application domain.

NoteNote

See How to: Compile and Run a Basic Remoting Application for complete instructions on how to build and run this sample.

To build a remotable type

  • Define a class that derives from the MarshalByRefObject class.

    Visual Basic
              
   Public Class RemotableType
      Inherits MarshalByRefObject
    …
End Class
public class RemotableType : MarshalByRefObject
{
    …
}

Example

Visual Basic
' RemotableType.vb
Imports System

Public Class RemotableType
   Inherits MarshalByRefObject 
   Public Function SayHello() As String
      Console.WriteLine("RemotableType.SayHello() was called!")
      Return "Hello, world"
   End Function 
End Class 
// RemotableType.cs
using System;
public class RemotableType : MarshalByRefObject
{
    public string SayHello()
    {
        Console.WriteLine("RemotableType.SayHello() was called!");
        return "Hello, world";
    }
}

See Also

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Incomplete?      MFF   |   Edit   |   Show History
This section is not complete, right?
Processing
© 2010 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker