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

我该怎么解决呢?


当前回答

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

其他回答

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

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

在我的例子中,问题的发生是因为我创建的类有一个干扰现有类的名称空间。新类A有命名空间zz.yy.xx(错误地)。对另一个命名空间yy中的对象的引用。xx没有在类A或命名空间为zz的其他类中编译。

我将A类的命名空间修改为yy。Xx,它应该是,而且它开始工作了。

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

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

我得到了一个非常类似的错误消息,这是由于无意中在我的解决方案的另一个项目中创建了一个类的副本而引起的。删除副本解决了这个问题

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