Export (0) Print
Expand All

ServiceHost.ServiceHost(Object, Uri[]) Constructor

Initializes a new instance of the ServiceHost class with the instance of the service and its base addresses specified.

Namespace: System.ServiceModel
Assembly: System.ServiceModel (in system.servicemodel.dll)

public ServiceHost (
	Object singletonInstance,
	params Uri[] baseAddresses
)
public ServiceHost (
	Object singletonInstance, 
	Uri[] baseAddresses
)
public function ServiceHost (
	singletonInstance : Object, 
	... baseAddresses : Uri[]
)
Not applicable.

Parameters

singletonInstance

The instance of the hosted service.

baseAddresses

An Array of type Uri that contains the base addresses for the hosted service.

Exception typeCondition

ArgumentNullException

singletonInstance is a null reference (Nothing in Visual Basic).

Use this constructor as an alternative to implementing a custom System.ServiceModel.Dispatcher.IInstanceContextInitializer when you want to provide a specific object instance for use by a singleton service. You may want to use this overload when your service implementation type is difficult to construct (for example, if it does not implement a default public constructor that has no parameters).

Note that when an object is provided to this overload, some features related to the Windows Communication Foundation (WCF) instancing behavior work differently. For example, calling InstanceContext.ReleaseServiceInstance have no effect when a well-known object instance is provided using this constructor overload. Similarly, any other instance release mechanism is ignored. The ServiceHost always behaves as if the OperationBehaviorAttribute.ReleaseInstanceMode property is set to ReleaseInstanceMode.None for all operations.

CalculatorService service = new CalculatorService();
ServiceHost serviceHost = new ServiceHost(service, baseAddress);

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

ADD
Show:
© 2015 Microsoft