RemotingConfiguration.RegisterWellKnownClientType Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Registers an object Type on the client end as a well-known type (single call or singleton).
Overloads
RegisterWellKnownClientType(WellKnownClientTypeEntry) |
Registers an object Type recorded in the provided WellKnownClientTypeEntry on the client end as a well-known type that can be activated on the server. |
RegisterWellKnownClientType(Type, String) |
Registers an object Type on the client end as a well-known type that can be activated on the server, using the given parameters to initialize a new instance of the WellKnownClientTypeEntry class. |
RegisterWellKnownClientType(WellKnownClientTypeEntry)
Registers an object Type recorded in the provided WellKnownClientTypeEntry on the client end as a well-known type that can be activated on the server.
public:
static void RegisterWellKnownClientType(System::Runtime::Remoting::WellKnownClientTypeEntry ^ entry);
public static void RegisterWellKnownClientType (System.Runtime.Remoting.WellKnownClientTypeEntry entry);
static member RegisterWellKnownClientType : System.Runtime.Remoting.WellKnownClientTypeEntry -> unit
Public Shared Sub RegisterWellKnownClientType (entry As WellKnownClientTypeEntry)
Parameters
- entry
- WellKnownClientTypeEntry
Configuration settings for the well-known type.
Exceptions
At least one of the callers higher in the callstack does not have permission to configure remoting types and channels.
Remarks
Any client that knows the URI of a registered well-known object can obtain a proxy for the object by registering the channel it prefers with ChannelServices, and activating the object by calling new
or Activator.GetObject. To activate a well-known object with new
, you must first register the well-known object type on the client using the RegisterWellKnownClientType method. Calling the RegisterWellKnownClientType method gives the remoting infrastructure the location of the remote object, which allows the new
keyword to create it. If, on the other hand, you use the Activator.GetObject method to activate the well-known object, you must supply it with the object's URL as an argument, so no prior registration on the client end is necessary.
For a detailed description of well-known objects, see Server Activation.
See also
Applies to
RegisterWellKnownClientType(Type, String)
Registers an object Type on the client end as a well-known type that can be activated on the server, using the given parameters to initialize a new instance of the WellKnownClientTypeEntry class.
public:
static void RegisterWellKnownClientType(Type ^ type, System::String ^ objectUrl);
public static void RegisterWellKnownClientType (Type type, string objectUrl);
static member RegisterWellKnownClientType : Type * string -> unit
Public Shared Sub RegisterWellKnownClientType (type As Type, objectUrl As String)
Parameters
- objectUrl
- String
URL of a well-known client object.
Exceptions
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 well-known type. For the server code that corresponds to the presented client code, see the example for the RegisterWellKnownServiceType 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::Tcp;
using namespace System::Runtime::Remoting::Channels;
int main()
{
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels.Tcp;
using System.Runtime.Remoting.Channels;
public class ClientClass {
public static void Main() {
Imports System.Runtime.Remoting
Imports System.Runtime.Remoting.Channels.Tcp
Imports System.Runtime.Remoting.Channels
Public Class ClientClass
Public Shared Sub Main()
ChannelServices::RegisterChannel( gcnew TcpChannel );
RemotingConfiguration::RegisterWellKnownClientType( HelloService::typeid,
"tcp://localhost:8082/HelloServiceApplication/MyUri" );
HelloService ^ service = gcnew HelloService;
ChannelServices.RegisterChannel(new TcpChannel());
RemotingConfiguration.RegisterWellKnownClientType(
typeof(HelloService),
"tcp://localhost:8082/HelloServiceApplication/MyUri"
);
HelloService service = new HelloService();
ChannelServices.RegisterChannel(New TcpChannel())
RemotingConfiguration.RegisterWellKnownClientType(GetType(HelloService), "tcp://localhost:8082/HelloServiceApplication/MyUri")
Dim service As New HelloService()
if ( service == nullptr )
{
Console::WriteLine( "Could not locate server." );
return -1;
}
// 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();
return 0;
}
if(service == null) {
Console.WriteLine("Could not locate server.");
return;
}
// 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();
}
}
If service Is Nothing Then
Console.WriteLine("Could not locate server.")
Return
End If
' 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()
End Sub
End Class
Remarks
Any client that knows the URI of a registered well-known object can obtain a proxy for the object by registering the channel it prefers with ChannelServices, and activating the object by calling new
or Activator.GetObject. To activate a well-known object with new
, you must first register the well-known object type on the client using the RegisterWellKnownClientType method. Calling the RegisterWellKnownClientType method gives the remoting infrastructure the location of the remote object, which allows the new
keyword to create it. If, on the other hand, you use the Activator.GetObject method to activate the well-known object, you must supply it with the object's URL as an argument, so no prior registration on the client end is necessary.
For a detailed description of well-known objects, see Server Activation.