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

我该怎么解决呢?


当前回答

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

其他回答

对于任何有链接文件的人:我有这个问题,正在使用silverlight和违规文件抛出这个错误是一个链接文件。

编译器的错误告诉我错误发生在文件所在的项目中。最终,错误不在该项目中,而是发生在包含链接文件的项目中。那个项目缺少一个参考。

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

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

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

我发现这是由于我使用了与类名相同的名称空间名(MyWorld。MyWorld = Namespace.ClassName)。

将您的命名空间更改为与您的类不同的名称,这将编译。