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

我该怎么解决呢?


当前回答

我也遇到了同样的问题,尝试了以上所有方法都没有成功,然后我发现了它是什么:

我在我的一个项目中创建了一个名为“System”的文件夹,然后在其中创建了一个类。问题似乎源于在创建.cs文件时有一个名为“System”的名称空间,即使它是在“MyProject.System”的名称空间中。

回顾过去,我可以理解为什么这会引起问题。起初它真的难住了我,因为错误消息最初似乎与问题无关。

其他回答

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

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

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

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

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

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

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

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