다음을 통해 공유


방법: 원격화할 수 있는 형식 빌드

MarshalByRefObject에서 상속된 클래스의 인스턴스만 다른 응용 프로그램 도메인에 있는 개체가 사용할 수 있습니다. 다음 절차에서는 다른 응용 프로그램 도메인에서 실행되는 개체를 통해 생성되고 호출될 수 있는 간단한 개체를 만드는 방법에 대해 설명합니다.

원격화할 수 있는 형식을 빌드하려면

  1. MarshalByRefObject 클래스에서 파생되는 클래스를 정의합니다.

    Public Class CustomRemotableException
        Inherits RemotingException
        …
    End Class
    
    public class CustomRemotableException : RemotingException, ISerializable {
        …
    }
    
  2. 원격화할 수 없는 형식에 대해 구현하는 것과 마찬가지로 이 클래스에 대해 메서드와 속성을 구현합니다.

    Private StringValue As String = "This is the RemotableType."
    Public Function StringMethod() As String
        Return StringValue
    End Function 'StringMethod
    
    private string StringValue = "This is the RemotableType.";
    public string StringMethod(){
        return StringVale;
    }
    
  3. 이 클래스를 Filename.language-extension으로 저장하거나 원하는 다른 파일 이름을 사용하여 저장하십시오. 여기에서 language extension은 컴파일하려는 언어입니다. 파일을 저장한 디렉터리의 명령 프롬프트에서 다음 명령을 입력합니다.

    vbc /t:library Filename.vb
    
    csc /noconfig /t:library RemotableType.cs
    

예제

' RemotableType.vb
Imports System

Public Class RemotableType
   Inherits MarshalByRefObject
   Private StringValue As String = "This is the RemotableType."
   
   Public Function StringMethod() As String
      Return StringValue
   End Function 'StringMethod
End Class 'RemotableType
// RemotableType.cs
using System;
public class RemotableType : MarshalByRefObject{
  private string StringValue = "This is the RemotableType.";
  public string StringMethod(){
    return StringVale;
  }
}

참고 항목

작업

방법: 호스팅 응용 프로그램 빌드

참조

원격 설정 스키마

개념

원격 응용 프로그램의 구성
서버 활성화

기타 리소스

기본 .NET Framework Remoting 응용 프로그램 빌드