In addition to other answers, I will try to add what I know to this topic.
In short, they both overwrite the default Name and Namespace of the [DataContract] and [DataMember] (Name) with whatever you supply to these properties.
According to the MS’s documentation for DataContractAttribute.Namespace property (they are called properties of the attribute, not attribute), on the 'Tip' section it states link, "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."
From what I have understood, for DataContract attribute to be able to serialize/deserialize the data, the data must have a matching namespace in both client and the server side, which might always not be the case in a real world situation. For instance, your data on the Server side, if named in a readable and sensible way, might be under the namespace that has a name something like "NameOfTheSolution.Server.NameOfTheProject," whereas on the client side, it could be something like "NameOfTheSolution.Client.NameOfTheProject." Due to different namespace the DataContracts are in, [DataContract] attribute won't be able serialize/deserialize the data between the client and server. I am not positive, but this could be the reason why it said method not allowed in your case, due to a mismatched namespace. In a situation where namespaces do not match, 'Namespace' property could be used while using the [DataContract] attribute and provide the class on the either side (client/server) with the same namespace, although they physically lay in different namespaces.
[DataContract (Namespace = “Whatever you want, usually uri”)]
public class User
{}
As far as the ‘Name’ property of the [DataContract] attribute goes, it overrides the name of your datacontract with the name you provide to this property. One use of it, in the context of DataMember attribute is to overload a method within a data contract. A DataContract doesn’t allow two DataMember with the same name, so in such scenario, ‘Name’ property is useful.