Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Namespace Property
Collapse the table of content
Expand the table of content

DataContractAttribute.Namespace Property

Gets or sets the namespace for the data contract for the type.

Namespace:  System.Runtime.Serialization
Assemblies:   System.Runtime.Serialization (in System.Runtime.Serialization.dll)
  System.Runtime.Serialization.Primitives (in System.Runtime.Serialization.Primitives.dll)

member Namespace : string with get, set

Property Value

Type: System.String
The namespace of the contract.

Use this property to specify a particular namespace if your type must return data that complies with a specific data contract.

TipTip

For the data to be successfully transmitted, the name of the data in a data contract must be the same in both the client and the server. Visual Basic projects, by default, add a prefix to the namespace defined in each file (called the “root namespace,” named after the project). Adding this prefix causes the client and server namespaces to be different for the same type. The solution is to set the Namespace property to “”, or to explicitly set the data contract namespace in this property.

.NET Framework

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

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone Silverlight 8.1, Windows Phone Silverlight 8

Portable Class Library

Supported in: Portable Class Library
Show:
© 2015 Microsoft