다음을 통해 공유


ActivatedClientTypeEntry 클래스

서버에서 활성화할 수 있는 형식으로 클라이언트 쪽에 등록된 개체 형식에 대한 값이 들어 있습니다.

네임스페이스: System.Runtime.Remoting
어셈블리: mscorlib(mscorlib.dll)

구문

‘선언
<ComVisibleAttribute(True)> _
Public Class ActivatedClientTypeEntry
    Inherits TypeEntry
‘사용 방법
Dim instance As ActivatedClientTypeEntry
[ComVisibleAttribute(true)] 
public class ActivatedClientTypeEntry : TypeEntry
[ComVisibleAttribute(true)] 
public ref class ActivatedClientTypeEntry : public TypeEntry
/** @attribute ComVisibleAttribute(true) */ 
public class ActivatedClientTypeEntry extends TypeEntry
ComVisibleAttribute(true) 
public class ActivatedClientTypeEntry extends TypeEntry

설명

클라이언트 활성 개체의 인스턴스를 클라이언트에 만들려면 해당 Type을 알아야 하고 RegisterActivatedClientType 메서드를 사용하여 이 인스턴스를 클라이언트에 등록해야 합니다. 클라이언트 활성 개체의 새 인스턴스에 대한 프록시를 얻으려면 먼저 클라이언트에서 채널을 ChannelServices에 등록한 다음 new를 호출하여 개체를 활성화해야 합니다.

클라이언트 활성 개체 형식을 new 키워드를 사용하여 활성화하려면 먼저 RegisterActivatedClientType 메서드를 사용하여 개체 형식을 클라이언트에 등록해야 합니다. RegisterActivatedClientType을 호출하면 new로 개체를 만들려는 원격 응용 프로그램의 위치를 원격 인프라에 알려 줄 수 있습니다. 반면에 Activator.CreateInstance 메서드를 사용하여 클라이언트 활성 개체의 새 인스턴스를 만들 경우에는 원격 응용 프로그램의 URL을 매개 변수로 제공해야 하므로 클라이언트 쪽에 미리 등록할 필요가 없습니다. 개체를 만들려는 서버의 URL을 가진 Activator.CreateInstance 메서드를 제공하려면 UrlAttribute 클래스의 인스턴스에서 URL을 캡슐화해야 합니다.

클라이언트 활성 개체 및 원격 개체 활성화에 대한 자세한 내용은 원격 개체의 활성화를 참조하십시오.

예제

다음 코드 예제에서는 ActivatedClientTypeEntry를 사용하여 클라이언트 활성 원격 개체를 등록하는 방법을 보여 줍니다. 이 예제에는 클라이언트 부분, 서버 부분, 그리고 클라이언트와 서버에서 사용하는 원격 개체 부분이 포함되어 있습니다.

다음 코드 예제에서는 클라이언트를 보여 줍니다.

Imports System
Imports System.Runtime.Remoting
Imports System.Runtime.Remoting.Channels
Imports System.Runtime.Remoting.Channels.Tcp

Public Class MyClient
    
    Public Shared Sub Main()
        ' Register TCP Channel.
        ChannelServices.RegisterChannel(New TcpChannel())

        ' Create activated client type entry.
        Dim myActivatedClientTypeEntry As _
            New ActivatedClientTypeEntry(GetType(HelloServer), _
            "tcp://localhost:8082")

        ' Register type on client to activate it on the server.
        RemotingConfiguration.RegisterActivatedClientType( _
            myActivatedClientTypeEntry)

        ' Activate a client activated object type.
        Dim myHelloServer As New HelloServer("ParameterString")

        ' Print the object type.
        Console.WriteLine("Object type of client activated object: " + _
            myActivatedClientTypeEntry.ObjectType.ToString())

        ' Print the application URL.
        Console.WriteLine("Application url where the type is activated: " + _
            myActivatedClientTypeEntry.ApplicationUrl)

        ' Print the string representation of the type entry.
        Console.WriteLine( _
            "Type name, assembly name and application URL " + _
            "of the remote object: " + _
            myActivatedClientTypeEntry.ToString())

        ' Print a blank line.
        Console.WriteLine()

        ' Check that server was located.
        If myHelloServer Is Nothing Then
            Console.WriteLine("Could not locate server")
        Else
            Console.WriteLine("Calling remote object")
            Console.WriteLine(myHelloServer.HelloMethod("Bill"))
        End If
    End Sub 'Main
End Class 'MyClient
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;

public class MyClient
{
    public static void Main()
    {
        // Register TCP Channel.
        ChannelServices.RegisterChannel(new TcpChannel());

        // Create activated client type entry.
        ActivatedClientTypeEntry myActivatedClientTypeEntry =
            new ActivatedClientTypeEntry(typeof(HelloServer),
            "tcp://localhost:8082");

        // Register type on client to activate it on the server.
        RemotingConfiguration.RegisterActivatedClientType(
            myActivatedClientTypeEntry);

        // Activate a client activated object type.
        HelloServer myHelloServer = new HelloServer("ParameterString");

        // Print the object type.
        Console.WriteLine(
            "Object type of client activated object: " +
            myActivatedClientTypeEntry.ObjectType.ToString());

        // Print the application URL.
        Console.WriteLine(
            "Application url where the type is activated: " +
            myActivatedClientTypeEntry.ApplicationUrl);

        // Print the string representation of the type entry.
        Console.WriteLine(
            "Type name, assembly name and application URL " +
            "of the remote object: " + 
            myActivatedClientTypeEntry.ToString());

        // Print a blank line.
        Console.WriteLine();

        // Check that server was located.
        if (myHelloServer == null)
        {
            Console.WriteLine("Could not locate server");
        }
        else
        {
            Console.WriteLine("Calling remote object");
            Console.WriteLine(myHelloServer.HelloMethod("Bill"));
        }
    }
}
#using <System.Runtime.Remoting.dll>
#using <ActivatedClientTypeEntry_Share.dll>

using namespace System;
using namespace System::Runtime::Remoting;
using namespace System::Runtime::Remoting::Channels;
using namespace System::Runtime::Remoting::Channels::Tcp;
static void main()
{
   // Register TCP Channel.
   ChannelServices::RegisterChannel( gcnew TcpChannel );
   
   // Create activated client type entry.
   ActivatedClientTypeEntry^ activatedClientTypeEntry = gcnew ActivatedClientTypeEntry( HelloServer::typeid, "tcp://localhost:8082" );
   
   // Register type on client to activate it on the server.
   RemotingConfiguration::RegisterActivatedClientType( activatedClientTypeEntry );
   
   // Activate a client activated object type.
   HelloServer^ helloServer = gcnew HelloServer( "ParameterString" );
   
   // Print the object type.
   Console::WriteLine( "Object type of client activated object: {0}", activatedClientTypeEntry->ObjectType->ToString() );
   
   // Print the application URL.
   Console::WriteLine( "Application url where the type is activated: {0}", activatedClientTypeEntry->ApplicationUrl->ToString() );
   
   // Print the string representation of the type entry.
   Console::WriteLine( "Type and assembly name and application URL of the remote object: {0}", activatedClientTypeEntry->ToString() );
   
   // Print a blank line.
   Console::WriteLine();
   
   // Check that server was located.
   if (  !helloServer )
   {
      Console::WriteLine( "Could not locate server" );
   }
   else
   {
      Console::WriteLine( "Calling remote object" );
      Console::WriteLine( helloServer->HelloMethod( "Bill" ) );
   }
}
import System.*;  
import System.Runtime.Remoting.*;  
import System.Runtime.Remoting.Channels.*;  
import System.Runtime.Remoting.Channels.Tcp.*;  

public class MyClient
{
    public static void main(String[] args)
    {
        // Register TCP Channel.
        ChannelServices.RegisterChannel(new TcpChannel());
        // Create activated client type entry.
        ActivatedClientTypeEntry myActivatedClientTypeEntry = 
            new ActivatedClientTypeEntry(HelloServer.class.ToType(), 
            "tcp://localhost:8082");
        // Register type on client to activate it on the server.
        RemotingConfiguration.RegisterActivatedClientType(
            myActivatedClientTypeEntry);
        // Activate a client activated object type.
        HelloServer myHelloServer = new HelloServer("ParameterString");
        // Print the object type.
        Console.WriteLine(("Object type of client activated object: " 
            + myActivatedClientTypeEntry.get_ObjectType().ToString()));
        // Print the application URL.
        Console.WriteLine("Application url where the type is activated: " 
            + myActivatedClientTypeEntry.get_ApplicationUrl());
        // Print the string representation of the type entry.
        Console.WriteLine("Type name, assembly name and application URL " 
            + "of the remote object: " + myActivatedClientTypeEntry.ToString());
        // Print a blank line.
        Console.WriteLine();
        // Check that server was located.
        if (myHelloServer == null) {
            Console.WriteLine("Could not locate server");
        }
        else {
            Console.WriteLine("Calling remote object");
            Console.WriteLine(myHelloServer.HelloMethod("Bill"));
        }
    } //main
} //MyClient

다음 코드 예제에서는 이 클라이언트에 대한 서버를 보여 줍니다.

Imports System
Imports System.Runtime.Remoting
Imports System.Runtime.Remoting.Channels
Imports System.Runtime.Remoting.Channels.Tcp

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

End Class 'MyServer
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;

public class MyServer
{
    public static void Main()
    {
        ChannelServices.RegisterChannel(new TcpChannel(8082));
        RemotingConfiguration.RegisterActivatedServiceType(typeof(HelloServer));
        Console.WriteLine("Press enter to stop this process");
        Console.ReadLine();
   }
}
#using <ActivatedClientTypeEntry_Share.dll>
#using <System.Runtime.Remoting.dll>

using namespace System;
using namespace System::Runtime::Remoting;
using namespace System::Runtime::Remoting::Channels;
using namespace System::Runtime::Remoting::Channels::Tcp;
void main()
{
   ChannelServices::RegisterChannel( gcnew TcpChannel( 8082 ) );
   RemotingConfiguration::RegisterActivatedServiceType( HelloServer::typeid );
   Console::WriteLine( "Press enter to stop this process" );
   Console::ReadLine();
}
import System.*;  
import System.Runtime.Remoting.*;  
import System.Runtime.Remoting.Channels.*;  
import System.Runtime.Remoting.Channels.Tcp.*;  

public class MyServer
{
    public static void main(String[] args)
    {
        ChannelServices.RegisterChannel(new TcpChannel(8082));
        RemotingConfiguration.RegisterActivatedServiceType(HelloServer.
            class.ToType());
        Console.WriteLine("Press enter to stop this process");
        Console.ReadLine();
    } //main
} //MyServer

다음 코드 예제에서는 클라이언트와 서버에서 사용하는 원격 개체를 제공합니다.

Imports System

Public Class HelloServer
    Inherits MarshalByRefObject
    
    Public Sub New(myString As String)
        Console.WriteLine("HelloServer activated")
        Console.WriteLine("Parameter passed to the constructor is " + myString)
    End Sub 'New
    
    Public Function HelloMethod(myName As String) As String
        Console.WriteLine("HelloMethod : {0}", myName)
        Return "Hi there " + myName
    End Function 'HelloMethod
End Class 'HelloServer
using System;
public class HelloServer : MarshalByRefObject
{
    public HelloServer(String myString)
    {
        Console.WriteLine("HelloServer activated");
        Console.WriteLine("Parameter passed to the constructor is "+myString);
    }
    public String HelloMethod(String myName)
    {
        Console.WriteLine("HelloMethod : {0}",myName);
        return "Hi there " + myName;
    }
}
using namespace System;
public ref class HelloServer: public MarshalByRefObject
{
public:
   HelloServer( String^ myString )
   {
      Console::WriteLine( "HelloServer activated" );
      Console::WriteLine( "Paramater passed to the constructor is {0}", myString );
   }

   String^ HelloMethod( String^ myName )
   {
      Console::WriteLine( "HelloMethod : {0}", myName );
      return String::Format( "Hi there {0}", myName );
   }

};
import System.*;  

public class HelloServer extends MarshalByRefObject
{
    public HelloServer(String myString)
    {
        Console.WriteLine("HelloServer activated");
        Console.WriteLine("Parameter passed to the constructor is " 
            + myString);
    } //HelloServer

    public String HelloMethod(String myName)
    {
        Console.WriteLine("HelloMethod : {0}", myName);
        return "Hi there " + myName;
    } //HelloMethod
} //HelloServer

상속 계층 구조

System.Object
   System.Runtime.Remoting.TypeEntry
    System.Runtime.Remoting.ActivatedClientTypeEntry

스레드로부터의 안전성

이 형식의 모든 public static(Visual Basic의 경우 Shared) 멤버는 스레드로부터 안전합니다. 인터페이스 멤버는 스레드로부터 안전하지 않습니다.

플랫폼

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

참고 항목

참조

ActivatedClientTypeEntry 멤버
System.Runtime.Remoting 네임스페이스
RegisterActivatedClientType

기타 리소스

클라이언트 활성화