tags:

views:

157

answers:

3

Is DataContract attribute is deprecated in ASP.NET 4.0 WCF ? I can see only DataContractFormat attribute.

I can't apply DataContractFormat attribute over struct.

example

[DataContractFormat]
public struct Contact
{
  public string firstName;
  public string lastName;
}

It throws an error saying that DataContractFormat artribute can only be used on class, interface and methods.

A: 

DataContract is not depreiated - wher ethe heck did you get that idea from?

DataCOntractFORMAT is sometihng totally different. I suggest you please read the documentation ;) Helps a of. WIll also explain what DataContractFormat is for.

http://msdn.microsoft.com/en-us/library/system.servicemodel.datacontractformatattribute.aspx

As you can see in the example this attribute goes on the class/interface that defines the SERVICE CONTRACT. It controls how for that service data serializaton is (guess what) formatted.

TomTom
+2  A: 

No, the .NET 4 still contains the DataContractAttribute:

http://msdn.microsoft.com/en-us/library/system.runtime.serialization.datacontractattribute%28v=VS.100%29.aspx

and it should be able to be applied to class or struct.

marc_s
A: 

You have to add a reference to the System.Runtime.Serialization assembly (right click References, add ref...)

Tal Fisher