方法 : リモート処理が可能な型を構築する

他のアプリケーション ドメインのオブジェクトがクラスのインスタンスを使用できるようにするには、クラスを MarshalByRefObject から継承する必要があります。次の手順は、別のアプリケーション ドメインで実行されているオブジェクトによって作成したり、呼び出したりできる基本的なオブジェクトの作成方法を示しています。

Noteメモ :

このサンプルの構築方法と実行方法の手順全体については、「方法 : 基本的なリモート処理アプリケーションをコンパイルして実行する」を参照してください。

リモート処理が可能な型を構築するには

  • MarshalByRefObject クラスから派生するクラスを定義します。

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

' 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";
    }
}

関連項目

タスク

方法 : ホスト アプリケーションを構築する
方法 : クライアント アプリケーションを構築する

参照

リモート処理設定スキーマ

概念

リモート アプリケーションの構成
サーバー アクティベーション

その他の技術情報

基本的な .NET Framework リモート処理アプリケーションの構築

Footer image

Copyright © 2007 by Microsoft Corporation.All rights reserved.