问题描述
我得到一个:
类型或命名空间名称找不到
错误在VS2010一个C#WPF应用程序。 code的这一区域被编译罚款,但突然间我发现了这个错误。我试着删除项目参考和使用
语句,VS2010关闭和重新启动,但我仍然有这个问题。
error for a C# WPF app in VS2010. This area of code was compiling fine, but suddenly I'm getting this error. I've tried removing the Project Reference and the using
statement, shutting VS2010 and restarting, but still I have this issue.
为什么这可能发生,在那里好像我做的事情写再参考和放任何想法; 使用
语句?
Any ideas why this might be occurring, where it seems like I'm doing the write thing re Reference & using
statement?
我也注意到在VS2010的智能感知该命名空间是工作好了,好像VS2010具有项目引用,看到一方面的命名空间,但是编译期间不看呢?
I also noted in VS2010 that intellisense for that namespace is working ok, so it seems like VS2010 has the project reference and seeing the namespace on one hand, but during compile doesn't see it?
推荐答案
这可能是两个项目之间的.NET Framework版本不兼容的结果。
This can be the result of a .Net framework version incompatibility between two projects.
它可以以两种方式发生:
It can happen in two ways:
- 一个客户端配置文件的项目引用一个完整的框架工程;或
- 的旧框架版本定位较新版本的框架
例如当一个应用程序设置为面向.NET 4客户端配置文件框架,它会发生,以及项目所引用目标的完整的.NET框架4
For example it will happen when an application is set to target the .Net 4 Client Profile framework, and the project it references targets the full .Net 4 framework.
因此,为了使这更清楚的:
So to make that clearer:
- A计划针对客户端配置框架
- 项目A引用项目B
- B项目目标的全面框架
在这种情况下,解决方案是升级应用程序(项目A)的框架目标,或降级引用的程序集(项目B)的目标。这是正常的完整的框架应用程序引用/消耗客户端配置框架组装,而不是倒过来(客户端配置不能引用完整的框架针对性组装)。
The solution in this case is to either upgrade the framework target of the application (Project A), or downgrade the target of referenced assembly (Project B). It is okay for a full framework app to reference/consume a client profile framework assembly, but not the other way round (client profile cannot reference full framework targeted assembly).
请注意,您也可以在创建在VS2012或VS2013(使用.NET 4.5作为默认架构)的新项目得到这个错误和:
Note that you can also get this error when you create a new project in VS2012 or VS2013 (which uses .Net 4.5 as the default framework) and:
-
引用项目(S)使用.NET 4.0(这是常见的,当你已迁移从VS2010到VS2012或VS2013,你再添加一个新的项目)
the referencing project(s) use .Net 4.0 (this is common when you have migrated from VS2010 to VS2012 or VS2013 and you then add a new project)
引用的项目中使用更大的版本,即4.5.1或4.5.3(你重新定位现有项目到最新版本,但仍然VS瞄准创建V4.5新项目,你再在新的项目引用这些旧项目)
the referenced projects use a greater version i.e. 4.5.1 or 4.5.3 (you've re-targeted your existing projects to the latest version, but VS still creates new projects targeting v4.5, and you then reference those older projects from the new project)
这篇关于获得"类型或命名空间名称找不到"但一切似乎好不好?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!