ServiceHost.ServiceHost(Type, Uri[]) Constructor

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

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

public ServiceHost (
	Type serviceType,
	params Uri[] baseAddresses
public ServiceHost (
	Type serviceType, 
	Uri[] baseAddresses
public function ServiceHost (
	serviceType : Type, 
	... baseAddresses : Uri[]
Not applicable.



The type of hosted service.


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

Exception typeCondition


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

Use this constructor when you have the service type and you can create new instances of it when needed, even when you need a singleton instance. Use the ServiceHost(Object,Uri[]) constructor instead only when you want the service host to use a specific singleton instance of the service.

This sample illustrates how to use the ServiceHost class to host a Windows Communication Foundation service:

ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService), 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