简体   繁体   中英

Type or namespace for datacontract

I've got the same problem as this post - Namespace for [DataContract] however the solution isn't the same.

I've already got System.Runtime.Serialization referenced in the project and i'm targeting .net4. This was the answer for the previous question

Interestingly VS color coding seems to think this is valid but it does not compile.

在此输入图像描述

References:

在此输入图像描述

Error messages are:

The type or namespace name 'DataContractAttribute' could not be found (are you missing a using directive or an assembly reference?)

Same for DataContract, DataMemberAttribute, DataMember.

The project i'm using defines a number of classes which i'm now wanting to serialize as data contracts and make available for another project. So this is not a WCF project but will be used in one later.

Thinking it may work I closed project and re-opened but still doesn't work.

Doh ! problem is exactly the same as the previous question. Two projects in this one solution; references added only to one of the projects; and the file in error was being used by both projects.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM