Programmatic Configuration

In some cases, programmatic configuration is useful. Although configuration files can be helpful for quick redirection without recompiling your application, you can also directly configure your remote types in the hosting application domain and in the client domain. The general requirements of configuration apply. The following code example shows a simple programmatic configuration of a listening application domain.

ChannelServices.RegisterChannel(New HttpChannel())
Dim WKSTE As New WellKnownServiceTypeEntry(GetType(ServiceClass), "HttpService", WellKnownObjectMode.SingleCall)
RemotingConfiguration.ApplicationName = "HttpService"
RemotingConfiguration.RegisterWellKnownServiceType(WKSTE)
[C#]
ChannelServices.RegisterChannel(new HttpChannel());
WellKnownServiceTypeEntry WKSTE = new WellKnownServiceTypeEntry(typeof(ServiceClass),"HttpService", WellKnownObjectMode.SingleCall);
RemotingConfiguration.ApplicationName = "HttpService";
RemotingConfiguration.RegisterWellKnownServiceType(WKSTE);

In more complex scenarios, such as programmatically publishing a particular instance of a remote object and then removing that object from publication, this type of configuration becomes a requirement. For details, see Advanced Remoting and Remoting Example: Dynamic Publication.

See Also

Configuration | RemotingConfiguration | ChannelServices