WCF分布式开发常见错误(4):The type or namespace name 'DataContract' could not be found DataContract找不到

来源:互联网 发布:java注解类 编辑:程序博客网 时间:2024/06/06 02:29
Posted on 2009-03-16 21:41 Frank Xu Lei 阅读(415) 评论(0)  编辑 收藏 网摘 所属分类: WCF分布式开发常见错误

我们进行WCF项目开发,自己定义数据契约的时候会出现这样的错误:

DataContract、DataMember、DataMemberAttribute找不到,如图:

The type or namespace name 'DataContract' could not be found (are you missing a using directive or an assembly reference?) E:/CodesVs2008/WCFServiceIISHostFrankXuLei/WcfServiceLib/WcfServiceLib/IService1.cs 24 6 WcfServiceLib

The type or namespace name 'DataMember' could not be found (are you missing a using directive or an assembly reference?) E:/CodesVs2008/WCFServiceIISHostFrankXuLei/WcfServiceLib/WcfServiceLib/IService1.cs 30 10 WcfServiceLib

The type or namespace name 'DataMemberAttribute' could not be found (are you missing a using directive or an assembly reference?) E:/CodesVs2008/WCFServiceIISHostFrankXuLei/WcfServiceLib/WcfServiceLib/IService1.cs 30 10 WcfServiceLib

解决办法,在项目里添加System.Runtime.Serialization程序集的引用。

生命引用程序集:

using System.Runtime.Serialization;

编译即可成功。


 

 

【老徐的博客】

【作者】:Frank Xu Lei

【地址】:http://www.cnblogs.com/frank_xl/archive/2009/03/16/1413752.html