WCF分布式开发常见错误解决(4)2011-03-31 博客园 Frank Xu LeiWCF分布式开发常见错误解决(4):The type or namespace name "DataContract" could not be found DataContract找不到我们进行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:CodesVs2008WCFServiceIISHostFrankXuLeiWcfServiceLibWcfServiceLibIService1.cs 24 6 WcfServiceLibThe type or namespace name "DataMember" could not be found (are you missing a using directive or an assembly reference?) E:CodesVs2008WCFServiceIISHostFrankXuLeiWcfServiceLibWcfServiceLibIService1.cs 30 10 WcfServiceLibThe type or namespace name "DataMemberAttribute" could not be found (are you missing a using directive or an assembly reference?) E:CodesVs2008WCFServiceIISHostFrankXuLeiWcfServiceLibWcfServiceLibIService1.cs 30 10 WcfServiceLib解决办法,在项目里添加System.Runtime.Serialization程序集的引用。生命引用程序集:using System.Runtime.Serialization;编译即可成功。