我得到一个:
找不到类型或名称空间名称
错误的c# WPF应用程序在VS2010。这部分代码编译得很好,但突然就出现了这个错误。我已经尝试删除项目引用和using语句,关闭VS2010并重新启动,但我仍然有这个问题。
有什么想法,为什么这可能会发生,似乎我在做正确的事情re Reference & using语句?
我还注意到在VS2010,智能感知的名称空间是工作的好,所以它似乎VS2010有项目引用,是看到名称空间在一方面,但在编译期间没有看到它?
我得到一个:
找不到类型或名称空间名称
错误的c# WPF应用程序在VS2010。这部分代码编译得很好,但突然就出现了这个错误。我已经尝试删除项目引用和using语句,关闭VS2010并重新启动,但我仍然有这个问题。
有什么想法,为什么这可能会发生,似乎我在做正确的事情re Reference & using语句?
我还注意到在VS2010,智能感知的名称空间是工作的好,所以它似乎VS2010有项目引用,是看到名称空间在一方面,但在编译期间没有看到它?
当前回答
把我的解决方案加入到混合中,因为它有点不同,我花了一段时间来弄清楚。
In my case I added a new class to one project but because my version control bindings weren't set I needed to make the file writable outside of Visual Studio (via the VC). I had cancelled out of the save in Visual Studio but after I made the file writable outside VS I then hit Save All again in VS. This inadvertently caused the new class file to not be saved in the project..however..Intellisense still showed it up as blue and valid in the referencing projects even though when I'd try to recompile the file wasn't found and got the type not found error. Closing and opening Visual Studio still showed the issue (but if I had taken note the class file was missing upon reopening).
当我意识到这一点时,解决方法很简单:将项目文件设置为可写,将丢失的文件读入项目。现在都建好了。
其他回答
我遇到的一个更棘手的情况是: 项目一的目标是安装了Microsoft.Bcl.Async包的4.0完整框架。 项目二的目标是4.0完整框架,但不会在引用项目一的类时编译。
一旦我在第二个项目上安装了Async NuGet包,它编译得很好。
把我的解决方案加入到混合中,因为它有点不同,我花了一段时间来弄清楚。
In my case I added a new class to one project but because my version control bindings weren't set I needed to make the file writable outside of Visual Studio (via the VC). I had cancelled out of the save in Visual Studio but after I made the file writable outside VS I then hit Save All again in VS. This inadvertently caused the new class file to not be saved in the project..however..Intellisense still showed it up as blue and valid in the referencing projects even though when I'd try to recompile the file wasn't found and got the type not found error. Closing and opening Visual Studio still showed the issue (but if I had taken note the class file was missing upon reopening).
当我意识到这一点时,解决方法很简单:将项目文件设置为可写,将丢失的文件读入项目。现在都建好了。
从VS 2019企业版“降级”到VS 2019专业版后开始出现这个问题。 尽管错误显示在“错误”窗口中,但我可以毫无问题地构建项目。 尝试了这个线程和其他线程的许多解决方案,如均衡目标框架,删除并重新引用,删除.suo文件等。 对我来说,有效的方法是删除本地存储库中的项目,并从远程存储库中再次克隆它。
它甚至发生在Visual Studio 2017中。
重启Visual Studio 无法构建的干净项目。 重新构建项目。
在我的VS2019解决方案中添加了一个新的库项目后,我得到了“使用系统”的错误。添加包Newtonsoft. json (currentversion)到库项目修复了这个问题,因为对Newtonsoft的依赖。Json包含了NETStandard。库的依赖项下的库,并正在生成一个警告图标。主项目有一个错误,直到我安装了Newtonsoft。Json,所以我认为它也适用于库;它确实做到了。