Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
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
)

Parameters

serviceImplementation
Type: System::Object

The Object that implements the service.

Return Value

Type: System.ServiceModel.Description::ServiceDescription
The ServiceDescription for the service object provided.

ExceptionCondition
ArgumentNullException

serviceImplementation is nullptr.

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 
			Dim svcObj As New CalculatorService()
			Dim sd3 As ServiceDescription = ServiceDescription.GetService(svcObj)
            Dim serviceName = sd3.Name
			Console.WriteLine("Service name: {0}", serviceName)
No code example is currently available or this language may not be supported.
ServiceDescription d = ServiceDescription.GetService(typeof(CalculatorService));
foreach (IServiceBehavior isb in d.Behaviors)
{
    Console.WriteLine(isb.GetType());
}
Console.WriteLine();

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft