Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
 Behaviors Property
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
ServiceDescription..::.Behaviors Property

Gets the behaviors associated with the service.

Namespace:  System.ServiceModel.Description
Assembly:  System.ServiceModel (in System.ServiceModel.dll)
Visual Basic (Declaration)
Public ReadOnly Property Behaviors As KeyedByTypeCollection(Of IServiceBehavior)
Visual Basic (Usage)
Dim instance As ServiceDescription
Dim value As KeyedByTypeCollection(Of IServiceBehavior)

value = instance.Behaviors
C#
public KeyedByTypeCollection<IServiceBehavior> Behaviors { get; }
Visual C++
public:
property KeyedByTypeCollection<IServiceBehavior^>^ Behaviors {
    KeyedByTypeCollection<IServiceBehavior^>^ get ();
}
JScript
public function get Behaviors () : KeyedByTypeCollection<IServiceBehavior>

Property Value

Type: System.Collections.Generic..::.KeyedByTypeCollection<(Of <(IServiceBehavior>)>)
The KeyedByTypeCollection<(Of <(TItem>)>) of type IServiceBehavior that contains the behaviors associated with the service.

Use this method when adding custom behaviors to extend ServiceHost. Programmatically, you must Add(T) the custom service behavior to the Behaviors prior to when you call the Open method on the ServiceHost object.

The type of behavior that is accessible from the description hierarchy is scoped to the specific level. From the ServiceDescription the IServiceBehavior is accessible.

If you want access to the IEndpointBehavior associated with an endpoint instead, you can obtain the endpoints for the service using the Endpoints property. Then retrieve the ServiceEndpoint from the collection with the Find method that employs the relevant search criteria, and call the Behaviors property to obtain the collection of the IEndpointBehavior objects.

C#
//// Iterate through the list of behaviors in the ServiceDescription
//ServiceDescription svcDesc = serviceHost.Description;
//KeyedByTypeCollection<IServiceBehavior> sbCol = svcDesc.Behaviors;
//foreach (IServiceBehavior behavior in sbCol)
//{
//    Console.WriteLine("Behavior: {0}", behavior.ToString());
//}

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker