다음을 통해 공유


RemotingConfiguration.RegisterActivatedServiceType 메서드

정의

서비스 끝의 개체를 클라이언트의 요청에 따라 활성화할 수 있는 개체 Type 로 등록합니다.

오버로드

Name Description
RegisterActivatedServiceType(ActivatedServiceTypeEntry)

서비스 끝에 제공된 개체 형식에 기록된 ActivatedServiceTypeEntry 개체 형식을 클라이언트의 요청에 따라 활성화할 수 있는 형식으로 등록합니다.

RegisterActivatedServiceType(Type)

서비스 끝에 지정된 개체 형식을 클라이언트의 요청에 따라 활성화할 수 있는 형식으로 등록합니다.

RegisterActivatedServiceType(ActivatedServiceTypeEntry)

서비스 끝에 제공된 개체 형식에 기록된 ActivatedServiceTypeEntry 개체 형식을 클라이언트의 요청에 따라 활성화할 수 있는 형식으로 등록합니다.

public:
 static void RegisterActivatedServiceType(System::Runtime::Remoting::ActivatedServiceTypeEntry ^ entry);
public static void RegisterActivatedServiceType(System.Runtime.Remoting.ActivatedServiceTypeEntry entry);
static member RegisterActivatedServiceType : System.Runtime.Remoting.ActivatedServiceTypeEntry -> unit
Public Shared Sub RegisterActivatedServiceType (entry As ActivatedServiceTypeEntry)

매개 변수

entry
ActivatedServiceTypeEntry

클라이언트 활성화 형식에 대한 구성 설정입니다.

예외

호출 스택에서 더 높은 호출자 중 하나 이상에는 원격 유형 및 채널을 구성할 수 있는 권한이 없습니다.

설명

서버에서 클라이언트 활성화 개체의 인스턴스를 만들려면 해당 개체를 알고 Type 있어야 하며 이 메서드를 사용하여 RegisterActivatedServiceType 서버 끝에 등록해야 합니다. 클라이언트 활성화 개체의 새 인스턴스에 대한 프록시를 가져오려면 클라이언트가 먼저 채널을 ChannelServices 등록한 다음, 호출 new 하거나 Activator.CreateInstance호출하여 개체를 활성화해야 합니다.

키워드를 사용하여 클라이언트 활성화 개체 형식을 new 활성화하려면 먼저 메서드를 사용하여 RegisterActivatedClientType 클라이언트 쪽에 개체 형식을 등록해야 합니다. 이 메서드를 RegisterActivatedClientType 호출하면 원격 인프라에 원격 애플리케이션을 만들려는 원격 애플리케이션 new 의 위치가 지정됩니다. 반면에 이 메서드를 사용하여 CreateInstance 클라이언트 활성화 개체의 새 인스턴스를 만드는 경우 원격 애플리케이션의 URL을 매개 변수로 제공해야 하므로 클라이언트 쪽에 사전 등록이 필요하지 않습니다. 메서드에 CreateInstance 개체를 만들려는 서버의 URL을 제공하려면 클래스 인스턴스 UrlAttribute 의 URL을 캡슐화해야 합니다.

추가 정보

적용 대상

RegisterActivatedServiceType(Type)

서비스 끝에 지정된 개체 형식을 클라이언트의 요청에 따라 활성화할 수 있는 형식으로 등록합니다.

public:
 static void RegisterActivatedServiceType(Type ^ type);
public static void RegisterActivatedServiceType(Type type);
static member RegisterActivatedServiceType : Type -> unit
Public Shared Sub RegisterActivatedServiceType (type As Type)

매개 변수

type
Type

Type 등록할 개체입니다.

예외

호출 스택에서 더 높은 호출자 중 하나 이상에는 원격 유형 및 채널을 구성할 수 있는 권한이 없습니다.

예제

다음 코드 예제에서는 클라이언트에서 활성화할 수 있는 형식으로 서버의 개체 형식 등록을 보여 줍니다. 제공된 서버 코드에 해당하는 클라이언트 코드는 메서드의 예제를 RegisterActivatedClientType 참조하세요.

#using <system.dll>
#using <system.runtime.remoting.dll>
#using "service.dll"

using namespace System;
using namespace System::Runtime::Remoting;
using namespace System::Runtime::Remoting::Channels;
using namespace System::Runtime::Remoting::Channels::Tcp;

int main()
{
   ChannelServices::RegisterChannel( gcnew TcpChannel( 8082 ) );
   RemotingConfiguration::RegisterActivatedServiceType( HelloServiceClass::typeid );
   Console::WriteLine( "Press enter to stop this process." );
   Console::ReadLine();
   return 0;
}
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;

public class ServerClass {

    public static void Main()  {

        ChannelServices.RegisterChannel(new TcpChannel(8082));

        RemotingConfiguration.RegisterActivatedServiceType(typeof(HelloServiceClass));

        Console.WriteLine("Press enter to stop this process.");
        Console.ReadLine();
    }
}
Imports System.Runtime.Remoting
Imports System.Runtime.Remoting.Channels
Imports System.Runtime.Remoting.Channels.Tcp


Public Class ServerClass
      
   Public Shared Sub Main()
      
      ChannelServices.RegisterChannel(New TcpChannel(8082))     
      RemotingConfiguration.RegisterActivatedServiceType(GetType(HelloServiceClass))
      
      Console.WriteLine("Press enter to stop this process.")
      Console.ReadLine()

   End Sub

End Class

다음 코드 예제에서는 위의 샘플 코드에 등록된 서비스 개체를 보여줍니다.

#using <system.dll>

using namespace System;

public ref class HelloServiceClass: public MarshalByRefObject
{
private:
   static int n_instance;

public:
   HelloServiceClass()
   {
      n_instance++;
      Console::WriteLine(  "{0} has been created.  Instance # = {1}", this->GetType()->Name, n_instance );
   }

   ~HelloServiceClass()
   {
      Console::WriteLine( "Destroyed instance {0} of HelloServiceClass.", n_instance );
      n_instance--;
   }

   String^ HelloMethod( String^ name )
   {
      // Reports that the method was called.
      Console::WriteLine();
      Console::WriteLine( "Called HelloMethod on instance {0} with the '{1}' parameter.", n_instance, name );

      // Calculates and returns the result to the client.
      return String::Format( "Hi there {0}", name );
   }
};
using System;

public class HelloServiceClass : MarshalByRefObject {

    static int n_instance;

    public HelloServiceClass() {
        n_instance++;
        Console.WriteLine(this.GetType().Name + " has been created.  Instance # = {0}", n_instance);
    }

    ~HelloServiceClass() {
        Console.WriteLine("Destroyed instance {0} of HelloServiceClass.", n_instance);
        n_instance --;
    }

    public String HelloMethod(String name) {

        // Reports that the method was called.
        Console.WriteLine();
        Console.WriteLine("Called HelloMethod on instance {0} with the '{1}' parameter.",
                             n_instance, name);

        // Calculates and returns the result to the client.
        return "Hi there " + name + ".";
    }
}
Public Class HelloServiceClass
   Inherits MarshalByRefObject
   
   Private Shared n_instance As Integer

      
   Public Sub New()
      n_instance += 1
      Console.WriteLine(Me.GetType().Name + " has been created.  Instance # = {0}", n_instance)
   End Sub
      
   
   Protected Overrides Sub Finalize()
      Console.WriteLine("Destroyed instance {0} of HelloServiceClass.", n_instance)
      n_instance -= 1
      MyBase.Finalize()
   End Sub
   
   
   
   Public Function HelloMethod(name As [String]) As [String]
      
      ' Reports that the method was called.
      Console.WriteLine()
      Console.WriteLine("Called HelloMethod on instance {0} with the '{1}' parameter.", n_instance, name)
      
      ' Calculates and returns the result to the client.
      Return "Hi there " + name + "."

   End Function 'HelloMethod

End Class

설명

서버에서 클라이언트 활성화 개체의 인스턴스를 만들려면 해당 개체를 알고 Type 있어야 하며 이 메서드를 사용하여 RegisterActivatedServiceType 서버 끝에 등록해야 합니다. 클라이언트 활성화 개체의 새 인스턴스에 대한 프록시를 가져오려면 클라이언트가 먼저 채널을 ChannelServices 등록한 다음, 호출 new 하거나 Activator.CreateInstance호출하여 개체를 활성화해야 합니다.

키워드를 사용하여 클라이언트 활성화 개체 형식을 new 활성화하려면 먼저 메서드를 사용하여 RegisterActivatedClientType 클라이언트 쪽에 개체 형식을 등록해야 합니다. 이 메서드를 RegisterActivatedClientType 호출하면 원격 인프라에 원격 애플리케이션을 만들려는 원격 애플리케이션 new 의 위치가 지정됩니다. 반면에 이 메서드를 사용하여 CreateInstance 클라이언트 활성화 개체의 새 인스턴스를 만드는 경우 원격 애플리케이션의 URL을 매개 변수로 제공해야 하므로 클라이언트 쪽에 사전 등록이 필요하지 않습니다. 메서드에 CreateInstance 개체를 만들려는 서버의 URL을 제공하려면 클래스 인스턴스 UrlAttribute 의 URL을 캡슐화해야 합니다.

추가 정보

적용 대상