类型或名称空间名称不存在

本文翻译自:Type or namespace name does not exist [closed]

Closed. 关闭。 This question is off-topic . 这个问题是题外话 It is not currently accepting answers. 它当前不接受答案。

Want to improve this question? 想改善这个问题吗? Update the question so it's on-topic for Stack Overflow. 更新问题 ,使其成为Stack Overflow 的主题

Closed 4 years ago . 4年前关闭。

I have a WCF Data Service project built with Visual Studio 2010, which was working fine. 我有一个使用Visual Studio 2010构建的WCF数据服务项目,该项目运行良好。 All of a sudden, it didn't compile anymore. 突然之间,它不再编译了。 It was giving me messages like: 它给我的消息是:

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 ... 错误7类型或名称空间名称'服务'在名称空间'System.Data'中不存在(是否缺少程序集引用?)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 错误8类型或名称空间名称'Linq'在名称空间'System'中不存在(您是否缺少程序集引用?)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?) 错误10类型或名称空间名称'Web'在名称空间'System.ServiceModel'中不存在(您是否缺少程序集引用?)

Error 12 The type or namespace name 'DataService' could not be found (are you missing a using directive or an assembly reference?) 错误12找不到类型或名称空间名称'DataService'(您是否缺少using指令或程序集引用?)

How can I fix it? 我该如何解决?


#1楼

参考:https://stackoom.com/question/NMTZ/类型或名称空间名称不存在


#2楼

I had an issue with System.Linq not being recognized. 我遇到了无法识别System.Linq的问题。 The using statement had a red squiggly, etc. The way I solved it was to change my website to target dotnet 3.5, then switch back to the original targeted framework (4.0 in my case). using语句带有红色波浪状等。我解决该问题的方法是将网站更改为目标dotnet 3.5,然后切换回原始目标框架(本例中为4.0)。


#3楼

Check to see that your target framework has the same .NET versions. 检查以确保您的目标框架具有相同的.NET版本。 I had the same problem and my class .NET was 3.5 and web solution had 4.5. 我遇到了同样的问题,我的课程.NET是3.5,Web解决方案是4.5。 I synchronised those, and then it worked :) 我同步了这些,然后就起作用了:)


#4楼

FOR ANYONE WITH LINKED FILES: I had this problem and was using silverlight and the offending file that was throwing this error was a linked file. 对于具有链接文件的任何人:我遇到了这个问题,正在使用silverlight,而引发此错误的有问题的文件是链接文件。

The error from the compiler told me the error was happening in the project that the file lived in. It ended up that the error was NOT in that project, it was occurring in the project that contained the linked file. 来自编译器的错误告诉我,该错误发生在文件所在的项目中。最终,该错误不在该项目中,而是在包含链接文件的项目中发生的。 That project was missing a reference. 该项目缺少参考。


#5楼

In my case the problem was happening because the class I created had a namespace that interfered with existing classes. 就我而言,问题之所以发生是因为我创建的类的名称空间会干扰现有类。 The new class A had namespace zz.yy.xx (by mistake). 新的类A具有名称空间zz.yy.xx(错误)。 References to objects in another namespace yy.xx were not compiling in class A or other classes whose namespace was zz. 对另一个名称空间yy.xx中的对象的引用未在A类或名称空间为zz的其他类中进行编译。

I changed the namespace of class A to yy.xx , which it should have been, and it started working. 我将类A的命名空间更改为yy.xx,它应该已经存在,并且开始工作。


#6楼

Delete the .refresh.dll file if you are under source control. 如果您在源代码控制下,请删除.refresh.dll文件。 Then rebuild. 然后重建。 It should work. 它应该工作。 This worked for me 这对我有用

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值