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

我该怎么解决呢?


当前回答

我正在引用Microsoft.CommerceServer.Runtime.Orders并遇到此错误。这个项目是旧的,有目标框架。net 2.0。在输出中,我有这个错误:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3268: The primary reference "Microsoft.CommerceServer.Runtime" could not be resolved because it has an indirect dependency on the framework assembly "System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v2.0". To resolve this problem, either remove the reference "Microsoft.CommerceServer.Runtime" or retarget your application to a framework version which contains "System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"

我简单地将目标框架更改为. net 4,现在就可以构建了。

其他回答

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

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

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

在我的案例中,项目没有任何变化,它只是停止编译,并且“类型或名称空间名称XXX不存在”,在抱怨类本身,XXX名称空间/类的智能感知工作正常。 问题确实出在参考文献上!

复制步骤:

解决方案有项目a,项目b。 ProjectA引用第三方log4net,并标记为Copy local: true。 projecb引用ProjectA,没有引用log4net。 解决方案编译良好。 ProjectA: log4net的引用属性更改为Copy local: false。 清理bin和obj文件夹。 当您编译时,ProjectA编译,但projecb抱怨找不到ProjectA名称空间。

这是因为ProjectB bin文件夹缺少第三方库(在我的情况下是log4net)!

在这种情况下,解是-

确保第三方库引用设置为Copy local: true 或 在引用路径下的项目属性中添加此类库的路径。

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

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

如果您处于源代码控制之下,请删除.refresh.dll文件。然后重建。它应该会起作用。 这对我很有效