Share via


Objects That Derive From MarshalByRefObject

Retired Content

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

The latest Enterprise Library information can be found at the Enterprise Library site.

If the target object already inherits from the abstract base class MarshalByRefObject, the necessary features are automatically available. The following code shows a simple object that inherits from MarshalByRefObject and exposes a single method and a single property.

public class OrderTransactions : MarshalByRefObject
{
  private string greeting;

  public int CountOrderItems(string customerName)
  {
    int orderCount = 0;
    // Code here to get count of number of orders from database.
    // ...
    return orderCount;
  }

  public string InvoiceGreeting
  {
    get { return greeting; }
    set { greeting = value; }
  }

}
'Usage
Public Class OrderTransactions
  Inherits MarshalByRefObject

  Private greeting As String

  Public Function CountOrderItems(ByVal customerName As String) As Integer
     Dim orderCount As Integer = 0
     ' Code here to get count of number of orders from database.
     ' ...
     Return orderCount
  End Function

  Public Property InvoiceGreeting() As String
    Get
      Return greeting
    End Get
    Set(ByVal value As String)
      greeting = value
    End Set
  End Property

End Class