ערוך

שתף באמצעות


RemotingConfiguration.RegisterActivatedClientType Method

Definition

Registers an object Type on the client end as a type that can be activated on the server.

Overloads

RegisterActivatedClientType(ActivatedClientTypeEntry)

Registers an object Type recorded in the provided ActivatedClientTypeEntry on the client end as a type that can be activated on the server.

RegisterActivatedClientType(Type, String)

Registers an object Type on the client end as a type that can be activated on the server, using the given parameters to initialize a new instance of the ActivatedClientTypeEntry class.

RegisterActivatedClientType(ActivatedClientTypeEntry)

Registers an object Type recorded in the provided ActivatedClientTypeEntry on the client end as a type that can be activated on the server.

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

Parameters

entry
ActivatedClientTypeEntry

Configuration settings for the client-activated type.

Exceptions

At least one of the callers higher in the callstack does not have permission to configure remoting types and channels.

Remarks

To create an instance of a client-activated object on the server, you must know its Type and it must be registered on the server end by using the RegisterActivatedServiceType method. To obtain a proxy for a new instance of the client-activated object, the client must first register a channel with ChannelServices and then activate the object by calling new.

To activate a client-activated object type with the new keyword, you must first register the object type on the client end using the RegisterActivatedClientType method. Calling the RegisterActivatedClientType method gives the remoting infrastructure the location of the remote application where new attempts to create it. If, on the other hand, you use the Activator.CreateInstance method to create a new instance of the client-activated object, you must supply the remote application's URL as a parameter, so no prior registration on the client end is necessary. To supply the Activator.CreateInstance method with the URL of the server where you want to create the object, you must encapsulate the URL in an instance of the UrlAttribute class.

For a detailed description of client-activated objects, see Client Activation.

See also

Applies to

RegisterActivatedClientType(Type, String)

Registers an object Type on the client end as a type that can be activated on the server, using the given parameters to initialize a new instance of the ActivatedClientTypeEntry class.

public:
 static void RegisterActivatedClientType(Type ^ type, System::String ^ appUrl);
public static void RegisterActivatedClientType (Type type, string appUrl);
static member RegisterActivatedClientType : Type * string -> unit
Public Shared Sub RegisterActivatedClientType (type As Type, appUrl As String)

Parameters

type
Type

The object Type.

appUrl
String

URL of the application where this type is activated.

Exceptions

The typeName or URI parameter is null.

At least one of the callers higher in the callstack does not have permission to configure remoting types and channels.

Examples

The following code example demonstrates registration of an object type on the client end as a type that can be activated on the server. For the server code that corresponds to the presented client code, see the example for the RegisterActivatedServiceType method.

#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 );
   RemotingConfiguration::RegisterActivatedClientType( HelloServiceClass::typeid, "tcp://localhost:8082" );
   try
   {
      HelloServiceClass ^ service = gcnew HelloServiceClass;

      // Calls the remote method.
      Console::WriteLine();
      Console::WriteLine( "Calling remote Object" );
      Console::WriteLine( service->HelloMethod( "Caveman" ) );
      Console::WriteLine( service->HelloMethod( "Spaceman" ) );
      Console::WriteLine( service->HelloMethod( "Client Man" ) );
      Console::WriteLine( "Finished remote Object call" );
    }
    catch (Exception ex)
    {
        Console::WriteLine("An exception occurred: " + ex.Message);
    }
   Console::WriteLine();
   return 0;
}
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;

public class ClientClass {

    public static void Main() {

        ChannelServices.RegisterChannel(new TcpChannel());

        RemotingConfiguration.RegisterActivatedClientType(typeof(HelloServiceClass),
                                                   "tcp://localhost:8082");

        try
        {
            HelloServiceClass service = new HelloServiceClass();

           // Calls the remote method.
           Console.WriteLine();
           Console.WriteLine("Calling remote object");
           Console.WriteLine(service.HelloMethod("Caveman"));
           Console.WriteLine(service.HelloMethod("Spaceman"));
           Console.WriteLine(service.HelloMethod("Client Man"));
           Console.WriteLine("Finished remote object call");
           Console.WriteLine();
        }
    catch (Exception ex)
    {
       Console.WriteLine("An exception occurred: " + ex.Message);
        }
    }
}
Imports System.Runtime.Remoting
Imports System.Runtime.Remoting.Channels
Imports System.Runtime.Remoting.Channels.Tcp


Public Class ClientClass
   
   Public Shared Sub Main()
      
      ChannelServices.RegisterChannel(New TcpChannel())
      
      RemotingConfiguration.RegisterActivatedClientType(GetType(HelloServiceClass), "tcp://localhost:8082")
      
      Try
          Dim service As New HelloServiceClass()
      
       
          ' Calls the remote method.
          Console.WriteLine()
          Console.WriteLine("Calling remote object")
          Console.WriteLine(service.HelloMethod("Caveman"))
          Console.WriteLine(service.HelloMethod("Spaceman"))
          Console.WriteLine(service.HelloMethod("Client Man"))
          Console.WriteLine("Finished remote object call")
      Catch ex as Exception
          Console.WriteLine("An exception occurred: " + ex.Message)
      End Try

      Console.WriteLine()

   End Sub

End Class

Remarks

To create an instance of a client-activated object on the server, you must know its Type and it must be registered on the server end by using the RegisterActivatedServiceType method. To obtain a proxy for a new instance of the client-activated object, the client must first register a channel with ChannelServices and then activate the object by calling new.

To activate a client-activated object type with the new keyword, you must first register the object type on the client end using the RegisterActivatedClientType method. Calling the RegisterActivatedClientType method gives the remoting infrastructure the location of the remote application where new attempts to create it. If, on the other hand, you use the Activator.CreateInstance method to create a new instance of the client-activated object, you must supply the remote application's URL as a parameter, so no prior registration on the client end is necessary. To supply the Activator.CreateInstance method with the URL of the server where you want to create the object, you must encapsulate the URL in an instance of the UrlAttribute class.

For a detailed description of client-activated objects, see Client Activation.

See also

Applies to