AddressHeader.CreateAddressHeader Method (String, String, Object, XmlObjectSerializer)

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Creates a new instance of the AddressHeader class with a specified name and namespace that uses a specified formatter to serialize the information item from a specified object.

Namespace:  System.ServiceModel.Channels
Assembly:  System.ServiceModel (in System.ServiceModel.dll)

Syntax

'Declaration
Public Shared Function CreateAddressHeader ( _
    name As String, _
    ns As String, _
    value As Object, _
    serializer As XmlObjectSerializer _
) As AddressHeader
public static AddressHeader CreateAddressHeader(
    string name,
    string ns,
    Object value,
    XmlObjectSerializer serializer
)

Parameters

  • value
    Type: System.Object
    The information item for the address header.

Return Value

Type: System.ServiceModel.Channels.AddressHeader
The AddressHeader with the specified name and ns that contains the information item specified by value.

Exceptions

Exception Condition
ArgumentNullException

name or serializer is nulla null reference (Nothing in Visual Basic) or name.Length == 0.

Examples

The following example shows how to create an address header using this method.

            'Create address headers with XmlObjectSerializer specified
            Dim serializer As XmlObjectSerializer = New DataContractSerializer(GetType(Integer))
            Dim addressHeaderWithObjSer As AddressHeader = AddressHeader.CreateAddressHeader("MyServiceName", "https://localhost:8000/service", 1, serializer)
            Dim value As Integer = addressHeaderWithObjSer.GetValue(Of Integer)()
//Create address headers with XmlObjectSerializer specified
XmlObjectSerializer serializer = new DataContractSerializer(typeof(int));
AddressHeader addressHeaderWithObjSer = AddressHeader.CreateAddressHeader("MyServiceName", "https://localhost:8000/service", 1, serializer);
int value = addressHeaderWithObjSer.GetValue<int>();

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.