Server-activated or client-activated objects are normally registered in the Web.config file when they are hosted through Internet Information Services (IIS), or in the application configuration file when the objects are hosted directly. Place all objects that the application hosts inside the <service> element.
When publishing server-activated (<wellknown>) objects, you must indicate whether the object is a SingleCall or Singleton object, the type of the object, and the endpoint where the object can be accessed. When publishing client-activated (<activated>) objects, you must indicate only the type of the object. The following example shows how to register a server-activated object and a client-activated object for a host application domain.
<configuration> <system.runtime.remoting> <application> <service> <wellknown mode = "SingleCall" type = "myType,myAssembly" objectUri = "myType.soap" /> <activated type="MyActivatedType, TypeAssembly" /> </service> </application> </system.runtime.remoting> </configuration>
The type attribute in the <activated> tag indicates the full type name and assembly name of the object, as it appears in the <wellknown> tag.
Configuring Server-Activated Types With IIS
If you intend to host your remote service in Internet Information Services to take advantage of the benefits IIS provides, there are some slight changes you must make to your configuration file. You can use the Web.config file to configure IIS to handle requests for your type automatically, or you can use the Application_Start handler in the Global.asax file to load your configuration file using RemotingConfiguration.Configure and passing the name of your configuration file. In either case:
- Do not specify an application name using the name attribute of the <application> tag. The virtual directory you create to host your remotable type will be the application name to clients of your type.
- Do not specify a port using the port attribute of a <channel> tag inside an <application> tag. If IIS creates a new thread to serve an increased number of requests, a new channel might be created, but an exception will be thrown because that port is already in use by the original channel. Instead, specify the port to use in Internet Services Manager. .NET remoting services will handle any requests for your remotable type on that port.