public ServiceHost Start(ApplicationConfiguration configuration, params Uri[] baseAddresses)
{
if (configuration == null) throw new ArgumentNullException("configuration");
// do any pre-startup processing
OnServerStarting(configuration);
// intialize the request queue from the configuration.
InitializeRequestQueue(configuration);
// create the binding factory.
BindingFactory bindingFactory = BindingFactory.Create(configuration, MessageContext);
// initialize the base addresses.
InitializeBaseAddresses(configuration);
// initialize the hosts.
ApplicationDescription serverDescription = null;
EndpointDescriptionCollection endpoints = null;
IList<ServiceHost> hosts = InitializeServiceHosts(
configuration,
bindingFactory,
out serverDescription,
out endpoints);
// save discovery information.
ServerDescription = serverDescription;
m_endpoints = new ReadOnlyList<EndpointDescription>(endpoints);
// start the application.
StartApplication(configuration);
// the configuration file may specify multiple security policies or non-HTTP protocols
// which will require multiple service hosts. the default host will be opened by WCF when
// it is returned from this function. The others must be opened here.
if (hosts == null || hosts.Count == 0)
{
throw ServiceResultException.Create(StatusCodes.BadConfigurationError, "The UA server does not have a default host.");
}
lock (m_hosts)
{
for (int ii = 1; ii < hosts.Count; ii++)
{
hosts[ii].Open();
m_hosts.Add(hosts[ii]);
}
}
return hosts[0];
}