Export (0) Print
Expand All

ServiceDescription.GetService Method (Object)

Returns a service description initialized with a specified service object.

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

public static ServiceDescription GetService (
	Object serviceImplementation
)
public static ServiceDescription GetService (
	Object serviceImplementation
)
public static function GetService (
	serviceImplementation : Object
) : ServiceDescription
Not applicable.

Parameters

serviceImplementation

The Object that implements the service.

Return Value

The ServiceDescription for the service object provided.

Exception typeCondition

ArgumentNullException

serviceImplementation 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(Object) initializes the Name, Namespace, and ConfigurationName properties, and ensures that the ServiceBehaviorAttribute is attached to the service and adds any relevant service behaviors to Behaviors.

The following sample shows how to iterate through the service behaviors contained in the service description.

// Instantiate a service description specifying a service object
// Note: Endpoints collection and other properties will be null since 
// we have not specified them
CalculatorService svcObj = new CalculatorService();
ServiceDescription sd3 = ServiceDescription.GetService(svcObj);
String serviceName = sd3.Name;
Console.WriteLine("Service name: {0}", serviceName);

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:
© 2014 Microsoft