我有一个用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,现在就可以构建了。

其他回答

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

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

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

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

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

我正在引用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,现在就可以构建了。

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

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