如何解决“名称空间Y中不存在类型或名称空间名称X"的错误提示? [英] How do I fix error saying "The type or namespace name X does not exist in the namespace Y"?

查看:77
本文介绍了如何解决“名称空间Y中不存在类型或名称空间名称X"的错误提示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我之前已经多次收到此错误,这是一个简单的解决方法-只需添加缺少的参考即可.但是,我已经有.实际上,添加引用后,intellisense可以将我引导至要引用的类型.但是,当我构建时,我得到了错误.从那以后,智能感知就不起作用了(给我红色的波浪形).我怀疑一件奇怪的事.我要添加引用的项目是一个.NET 4.0应用程序项目(使用LINQ和WPF).我正在尝试添加对.NET 3.5类库项目的引用.这对我来说是新水域(.NET 4.0引用.NET 3.5),但是我猜测程序集之间存在一些冲突.有什么想法吗?

I've gotten this error many times before, and it's a simple fix--just add the missing reference. However, I already have. In fact, after I add the reference, intellisense is able to guide me to the type I want to reference. But, when I build, I get the error. From there on out, intellisense does not work (gives me red squigglies). One odd thing that I am suspecting. The project I am trying to add the reference to is a .NET 4.0 application project (using LINQ and WPF). I am trying to add a reference to a .NET 3.5 class library project. This is new waters to me (.NET 4.0 referencing .NET 3.5) but I'm guessing there are some conflicts between the assemblies. Any ideas?

不确定这是否有帮助,但听起来人们需要一些代码.这就是我所做的.

Not sure if this will help but sounds like people need some code. This is all I did.

  1. 添加了对Project Framework.UserServices的引用.
  2. 对象浏览器中存在经过验证的中继命令类型,其名称空间为Framework.UserServices.
  3. 在现有类的构造函数中添加了以下代码(可以将其放置在任何地方).

  1. Added reference to project Framework.UserServices.
  2. Verified Relay Command type existed in Object Browser with namespace of Framework.UserServices.
  3. Added following code in constructor of existing class (could have put it anywhere).

Framework.UserServices.RelayCommand中继=新Framework.UserServices.RelayCommand(OpenEditor);

Framework.UserServices.RelayCommand relay = new Framework.UserServices.RelayCommand(OpenEditor);

推荐答案

通过在解决方案资源管理器中右键单击该项目,选择属性",然后单击应用程序"选项卡,检查.NET 4.0项目的构建目标是什么.如果目标是".NET Framework 4客户端配置文件",请尝试将其切换为普通的(非客户端).NET Framework 4.0"配置文件.

Check what the build target for your .NET 4.0 project is by right clicking the project in the Solution Explorer, selecting Properties, then clicking the "Application" tab. If it is targeting the ".NET Framework 4 Client Profile", try switching it to just plain (non-client) ".NET Framework 4.0" profile.

这篇关于如何解决“名称空间Y中不存在类型或名称空间名称X"的错误提示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆