public class RemotingConfiguration
|
ApplicationId | Read-only Gets the ID of the currently executing application. |
ApplicationName | Read-write Gets or sets the name of a remoting application. |
ProcessId | Read-only Gets the ID of the currently executing process. |
Configure | Reads the configuration file and configures the remoting infrastructure. |
Equals (inherited from System.Object) |
See base class member description: System.Object.Equals Derived from System.Object, the primary base class for all objects. |
GetHashCode (inherited from System.Object) |
See base class member description: System.Object.GetHashCode Derived from System.Object, the primary base class for all objects. |
GetRegisteredActivatedClientTypes | Retrieves an array of object types registered on the client as types that will be activated remotely. |
GetRegisteredActivatedServiceTypes | Retrieves an array of object types registered on the service end that can be activated on request from a client. |
GetRegisteredWellKnownClientTypes | Retrieves an array of object types registered on the client end as well-known types. |
GetRegisteredWellKnownServiceTypes | Retrieves an array of object types registered on the service end as well-known types. |
GetType (inherited from System.Object) |
See base class member description: System.Object.GetType Derived from System.Object, the primary base class for all objects. |
IsActivationAllowed | Returns a Boolean value indicating whether the specified Type is allowed to be client activated. |
IsRemotelyActivatedClientType | Overloaded:IsRemotelyActivatedClientType(Type svrType) Checks whether the specified object Type is registered as a remotely activated client type. |
IsRemotelyActivatedClientType | Overloaded:IsRemotelyActivatedClientType(string typeName, string assemblyName) Checks whether the object specified by its type name and assembly name is registered as a remotely activated client type. |
IsWellKnownClientType | Overloaded:IsWellKnownClientType(Type svrType) Checks whether the specified object Type is registered as a well-known client type. |
IsWellKnownClientType | Overloaded:IsWellKnownClientType(string typeName, string assemblyName) Checks whether the object specified by its type name and assembly name is registered as a well-known client type. |
RegisterActivatedClientType | Overloaded:RegisterActivatedClientType(ActivatedClientTypeEntry entry) Registers an object Type recorded in the provided ActivatedClientTypeEntry on the client end as a type that can be activated on the server. |
RegisterActivatedClientType | Overloaded:RegisterActivatedClientType(Type type, string appUrl) 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. |
RegisterActivatedServiceType | Overloaded:RegisterActivatedServiceType(ActivatedServiceTypeEntry entry) Registers an object type recorded in the provided ActivatedServiceTypeEntry on the service end as one that can be activated on request from a client. |
RegisterActivatedServiceType | Overloaded:RegisterActivatedServiceType(Type type) Registers a specified object type on the service end as a type that can be activated on request from a client. |
RegisterWellKnownClientType | Overloaded:RegisterWellKnownClientType(WellKnownClientTypeEntry entry) 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 | Overloaded:RegisterWellKnownClientType(Type type, string objectUrl) 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. |
RegisterWellKnownServiceType | Overloaded:RegisterWellKnownServiceType(WellKnownServiceTypeEntry entry) Registers an object Type recorded in the provided WellKnownServiceTypeEntry on the service end as a well-known type. |
RegisterWellKnownServiceType | Overloaded:RegisterWellKnownServiceType(Type type, string objectUri, WellKnownObjectMode mode) Registers an object Type on the service end as a well-known type, using the given parameters to initialize a new instance of WellKnownServiceTypeEntry. |
ToString (inherited from System.Object) |
See base class member description: System.Object.ToString Derived from System.Object, the primary base class for all objects. |
Finalize (inherited from System.Object) |
See base class member description: System.Object.Finalize Derived from System.Object, the primary base class for all objects. |
MemberwiseClone (inherited from System.Object) |
See base class member description: System.Object.MemberwiseClone Derived from System.Object, the primary base class for all objects. |
Hierarchy:
public static string ApplicationId {get;}
|
public static string ApplicationName {get; set;}
|
ChannelServices.RegisterChannel(new TcpChannel(8082)); RemotingConfiguration.ApplicationName = "HelloServiceApplication"; RemotingConfiguration.RegisterWellKnownServiceType( typeof(HelloService), "MyUri", WellKnownObjectMode.SingleCall );
The following example demonstrates how to access an object remoted from a named application.
ChannelServices.RegisterChannel(new TcpChannel()); RemotingConfiguration.RegisterWellKnownClientType( typeof(HelloService), "tcp://localhost:8082/HelloServiceApplication/MyUri" ); HelloService service = new HelloService();
public static string ProcessId {get;}
|
public static void Configure( |
filename
For configuration file syntax, see .
~RemotingConfiguration(); |
public virtual int GetHashCode(); |
public static ActivatedClientTypeEntry[] GetRegisteredActivatedClientTypes(); |
public static ActivatedServiceTypeEntry[] GetRegisteredActivatedServiceTypes(); |
public static WellKnownClientTypeEntry[] GetRegisteredWellKnownClientTypes(); |
For a more detailed description of well-known objects see the conceptual topic at MSDN: serveractivation.
public static WellKnownServiceTypeEntry[] GetRegisteredWellKnownServiceTypes(); |
For a more detailed description of well-known objects see the conceptual topic at MSDN: serveractivation.
public Type GetType(); |
svrType
public static ActivatedClientTypeEntry IsRemotelyActivatedClientType( |
svrType
public static ActivatedClientTypeEntry IsRemotelyActivatedClientType( |
typeName
assemblyName
public static WellKnownClientTypeEntry IsWellKnownClientType( |
svrType
public static WellKnownClientTypeEntry IsWellKnownClientType( |
typeName
assemblyName
protected object MemberwiseClone(); |
public static void RegisterActivatedClientType( |
entry
To activate a client activated object type with the new keyword, you must first register the object type on the client end using the RemotingConfiguration.RegisterActivatedClientType method. Calling the RemotingConfiguration.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 the conceptual topic at MSDN: clientactivation.
type
appUrl
Exception Type | Condition |
---|---|
ArgumentNullException | The typeName or URI parameter is null. |
To activate a client activated object type with the new keyword, you must first register the object type on the client end using the RemotingConfiguration.RegisterActivatedClientType method. Calling the RemotingConfiguration.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 the conceptual topic at MSDN: clientactivation
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"); HelloServiceClass service = new HelloServiceClass(); 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(); } }
public static void RegisterActivatedServiceType( |
entry
To activate a client activated object type with the new keyword, you must first register the object type on the client end using the RemotingConfiguration.RegisterActivatedClientType method. Calling the RemotingConfiguration.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 the conceptual topic at MSDN: clientactivation.
public static void RegisterActivatedServiceType( |
type
To activate a client activated object type with the new keyword, you must first register the object type on the client end using the RemotingConfiguration.RegisterActivatedClientType method. Calling the RemotingConfiguration.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 the conceptual topic at MSDN: clientactivation.
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(); } }
The following example shows the service object registered in the sample code above.
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 static void RegisterWellKnownClientType( |
entry
For a detailed description of well-known objects see the conceptual topic at MSDN: serveractivation.
type
objectUrl
For a detailed description of well-known objects see the conceptual topic at MSDN: serveractivation.
using System; using System.Runtime.Remoting; using System.Runtime.Remoting.Channels.Tcp; using System.Runtime.Remoting.Channels; public class ClientClass { public static void Main() { . . . ChannelServices.RegisterChannel(new TcpChannel()); RemotingConfiguration.RegisterWellKnownClientType( typeof(HelloService), "tcp://localhost:8082/HelloServiceApplication/MyUri" ); HelloService service = new HelloService(); . . . 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(); } }
public static void RegisterWellKnownServiceType( |
entry
When the call arrives at the server, .NET Framework extracts the URI from the message, examines the remoting tables to locate the reference for the object that matches the URI, and then instantiates the object if necessary, forwarding the method call to the object. If the object is registered as WellKnownObjectMode.SingleCall, it is destroyed after the method call is completed. A new instance of the object is created for each method called. The only difference between Activator.GetObject and new is that the former allows you to specify a URL as a parameter, and the latter obtains the URL from the configuration.
The remote object itself is not instantiated by the registration process. This only happens when a client attempts to call a method on the object or activates the object from the client side.
For a detailed description of well-known objects see the conceptual topic at MSDN: serveractivation.
using System; using System.Runtime.Remoting; using System.Runtime.Remoting.Channels; using System.Runtime.Remoting.Channels.Http; using System.Runtime.Remoting.Messaging; using System.Runtime.Serialization; public class ObjRefExample { public static void Main() { ChannelServices.RegisterChannel(new HttpChannel(8090)); WellKnownServiceTypeEntry wkste = new WellKnownServiceTypeEntry(typeof(RemoteObject), "RemoteObject", WellKnownObjectMode.Singleton); RemotingConfiguration.RegisterWellKnownServiceType( wkste ); RemoteObject RObj = (RemoteObject)Activator.GetObject(typeof(RemoteObject), "http://localhost:8090/RemoteObject"); LocalObject LObj = new LocalObject(); RObj.Method1( LObj ); Console.WriteLine("Press Return to exit..."); Console.ReadLine(); } } public class RemoteObject : MarshalByRefObject { public void Method1(LocalObject param) { Console.WriteLine("Invoked: Method1({0})", param); } }
public static void RegisterWellKnownServiceType( |
type
objectUri
mode
When the call arrives at the server, the .NET Framework extracts the URI from the message, examines the remoting tables to locate the reference for the object that matches the URI, and then instantiates the object if necessary, forwarding the method call to the object. If the object is registered as WellKnownObjectMode.SingleCall, it is destroyed after the method call is completed. A new instance of the object is created for each method called. The only difference between Activator.GetObject and new is that the former allows you to specify a URL as a parameter, and the latter obtains the URL from the configuration.
The remote object itself is not instantiated by the registration process. This only happens when a client attempts to call a method on the object or activates the object from the client side.
For a detailed description of well-known objects see the conceptual topic at MSDN: serveractivation.
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.ApplicationName = "HelloServiceApplication"; RemotingConfiguration.RegisterWellKnownServiceType( typeof(HelloService), "MyUri", WellKnownObjectMode.SingleCall ); . . . Console.WriteLine("Press enter to stop this process."); Console.ReadLine(); } }
The following example shows the service object registered in the sample code above.
using System; public class HelloService : MarshalByRefObject { static int n_instances; public HelloService() { n_instances++; Console.WriteLine(""); Console.WriteLine("HelloService activated - instance # {0}.", n_instances); } ~HelloService() { Console.WriteLine("HelloService instance {0} destroyed.", n_instances); n_instances--; } public String HelloMethod(String name) { Console.WriteLine("HelloMethod called on HelloService instance {0}.", n_instances); return "Hi there " + name + "."; } }
public virtual string ToString(); |