You are creating a Windows Communication Foundation service by using Microsoft .NET Framework 3.5. The service will be hosted in a Console application. You need to configure the service by using a configuration file other than the default app.config file. Which code segment should you use?
A.
class MyServiceHost : ServiceHost
{
public MyServiceHost(Type serviceType, params Uri[] baseAddresses) : base(serviceType, baseAddresses) { }
protected override void InitializeRuntime() { //Load configuration here }
}
B.
class MyServiceHost : ServiceHost
{
public MyServiceHost(Type serviceType, params Uri[] baseAddresses) : base(serviceType, baseAddresses) { }
protected override void ApplyConfiguration() { //Load configuration here }
}
C.
class MyServiceHost : ServiceHost
{
public MyServiceHost(Type serviceType, params Uri[] baseAddresses) : base(serviceType, baseAddresses) { }
protected new void InitializeDescription(Type serviceType, UriSchemeKeyedCollection baseAddresses) { //Load configuration here. }
}
D.
class MyServiceHost : ServiceHost
{
public MyServiceHost(Type serviceType, params Uri[] baseAddresses) : base(serviceType, baseAddresses) { }
protected new void AddBaseAddress(Uri baseAddress) { //Load configuration here. }
}
Explanation:
Next, you may want your application to use the standard configuration file but override some of the settings. There are two options for this. The first option is to override ApplyConfiguration in ServiceHost. After calling the base ApplyConfiguration method, you have the default configuration loaded. You can do whatever additional processing you want at that point. The second option is to rewrite the configuration using the ConfigurationManager class. This is a part of the standard configuration package and doesn’t know anything about WCF. That means you have to be knowledgeable yourself in how WCF configuration is laid out.http://blogs.msdn.com/b/drnick/archive/2006/12/04/overriding-the-default-configuration-file.aspx