This documentation is archived and is not being maintained.

ServiceDescription.GetService Method (Type)

Returns a service description initialized with a specified service type.

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

public static ServiceDescription GetService (
	Type serviceType
public static ServiceDescription GetService (
	Type serviceType
public static function GetService (
	serviceType : Type
) : ServiceDescription
Not applicable.



The Type of the service.

Return Value

The ServiceDescription for the service type provided.

Exception typeCondition


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

Use this method to reflect on behaviors using the Windows Communication Foundation (WCF) programming model when replacing ServiceHostBase with you own hosting mechanism.

GetService(Type) initializes the Name, Namespace, and ConfigurationName properties, reflects on the type for any the ServiceBehaviorAttribute objects and adds them to Behaviors, and ensures that the ServiceBehaviorAttribute is attached to the service.

ServiceDescription d = ServiceDescription.GetService(new CalculatorService());
foreach (IServiceBehavior isb in d.Behaviors)

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