Compartilhar via


Programmatic Configuration

This topic is specific to a legacy technology that is retained for backward compatibility with existing applications and is not recommended for new development. Distributed applications should now be developed using the Windows Communication Foundation (WCF).

Programmatic configuration is useful in some cases. 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 application 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(1234))
Dim WKSTE As New WellKnownServiceTypeEntry(GetType(ServiceClass), "HttpService", WellKnownObjectMode.SingleCall)
RemotingConfiguration.ApplicationName = "HttpService"
RemotingConfiguration.RegisterWellKnownServiceType(WKSTE)
ChannelServices.RegisterChannel(new HttpChannel(1234));
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 more information, see Advanced Remoting and Remoting Example: Dynamic Publication.

See Also

Reference

RemotingConfiguration
ChannelServices

Concepts

Configuration of Remote Applications