我有一个用Visual Studio 2010构建的WCF数据服务项目,运行良好。突然,它不再编译了。它给我的信息是:

Error 7 The type or namespace name 'Services' does not exist in the namespace 'System.Data' (are you missing an assembly reference?) C:\U...s\Visual Studio 2010\Projects...\DataService.cs ... Error 8 The type or namespace name 'Linq' does not exist in the namespace 'System' (are you missing an assembly reference?) DependencyResolver.cs 3 14 Error 10 The type or namespace name 'Web' does not exist in the namespace 'System.ServiceModel' (are you missing an assembly reference?) Error 12 The type or namespace name 'DataService' could not be found (are you missing a using directive or an assembly reference?)

我该怎么解决呢?


当前回答

我在使用Visual Studio的Git集成管理项目时遇到了这个问题。出于某种原因,Windows Phone 8项目在针对x86时编译得很好,但当我将其设置为针对ARM时,它会编译失败,并提示“Advertising”不存在于Microsoft命名空间中。

我最终通过删除Microsoft.Advertising.*.dll引用并重新添加它来解决这个问题。

其他回答

我也犯过同样的错误。在我发现我的项目有错误的程序集名称(我从另一个项目复制了文件,名称空间有点混乱),并将其更改回来后,项目编译得很好。

我在ASP上也遇到过同样的问题。NET MVC站点时,我尝试使用LINQ到SQL。我通过以下方法解决了这个问题:

解决方案资源管理器->引用->右键单击System.Data.Linq ->本地复制(True)

我也遇到了同样的问题,尝试了以上所有方法都没有成功,然后我发现了它是什么:

我在我的一个项目中创建了一个名为“System”的文件夹,然后在其中创建了一个类。问题似乎源于在创建.cs文件时有一个名为“System”的名称空间,即使它是在“MyProject.System”的名称空间中。

回顾过去,我可以理解为什么这会引起问题。起初它真的难住了我,因为错误消息最初似乎与问题无关。

检查你的目标框架是否有相同的。net版本。我也遇到过同样的问题,我的课程。net是3.5,web解决方案是4.5。我同步了这些,然后它工作了:)

如果所有这些都失败了,比如确保目标框架是相同的,并且你在VS2010中处理WPF类库,只需重新启动Visual Studio。这对我很有帮助。