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

我该怎么解决呢?


当前回答

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

其他回答

我最近需要做一个系统还原,它导致我的几个文件改变/消失,我一直在恢复工作。其中一些是DLL文件。我使用源代码控制来检索整个项目,但我仍然遇到了类似的问题。我找到了这个答案,描述了您可能需要删除一个DLL并读取它来修复您的错误。这就是我的情况。

删除WebMatrix。WebData和读取它以及在WebMatrix中添加。数据修正了我的类型或命名空间名称“数据”不存在命名空间“WebMatrix”....的错误

我的系统出了点问题。Linq没有被认出来。using语句有一个红色的、弯弯曲曲的等等。我解决这个问题的方法是将我的网站更改为目标dotnet 3.5,然后切换回原来的目标框架(在我的情况下是4.0)。

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

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

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

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