我有一个用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?)

我该怎么解决呢?


当前回答

我的系统出了点问题。Linq没有被认出来。using语句有一个红色的、弯弯曲曲的等等。我解决这个问题的方法是将我的网站更改为目标dotnet 3.5,然后切换回原来的目标框架(在我的情况下是4.0)。

其他回答

我也遇到过同样的问题,我必须将所有项目的“目标框架”设置为相同的。然后它建得很好。在项目菜单上,单击ProjectName属性。单击compile选项卡。单击高级编译选项。在目标框架中,选择所需的框架。

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

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

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

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

我在System.Data.SQLite中也遇到了同样的问题。问题的根源是您所使用的dll应该与您的项目具有相同的. net版本。

例如,如果你在。net 4.5上使用了SQLite(在我的情况下),那么你的平台目标也应该是。net 4.5。

您可以通过以下方式找到平台目标:项目>(项目名称)属性> Build。

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