简体   繁体   English

如何解决“名称空间Y中不存在类型或名称空间名称X”的错误?

[英]How do I fix error saying “The type or namespace name X does not exist in the namespace Y”?

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. 实际上,添加引用后,intellisense可以将我引导至要引用的类型。 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). 我要添加引用的项目是一个.NET 4.0应用程序项目(使用LINQ和WPF)。 I am trying to add a reference to a .NET 3.5 class library project. 我正在尝试添加对.NET 3.5类库项目的引用。 This is new waters to me (.NET 4.0 referencing .NET 3.5) but I'm guessing there are some conflicts between the assemblies. 这对我来说是新水域(.NET 4.0引用.NET 3.5),但是我猜测程序集之间存在一些冲突。 Any ideas? 有任何想法吗?

[Edit] [编辑]

Not sure if this will help but sounds like people need some code. 不知道这是否有帮助,但听起来人们需要一些代码。 This is all I did. 这就是我所做的。

  1. Added reference to project Framework.UserServices. 添加了对项目Framework.UserServices的引用。
  2. Verified Relay Command type existed in Object Browser with namespace of Framework.UserServices. 对象浏览器中存在带有Framework.UserServices命名空间的经过验证的中继命令类型。
  3. Added following code in constructor of existing class (could have put it anywhere). 在现有类的构造函数中添加了以下代码(可以将其放在任何地方)。

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

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. 通过在解决方案资源管理器中右键单击该项目,选择“属性”,然后单击“应用程序”选项卡,检查.NET 4.0项目的构建目标是什么。 If it is targeting the ".NET Framework 4 Client Profile", try switching it to just plain (non-client) ".NET Framework 4.0" profile. 如果它的目标是“ .NET Framework 4客户端配置文件”,请尝试将其切换为普通(非客户端)“。NET Framework 4.0”配置文件。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 名称空间“using:Y”中不存在名称“X” - The name "X" does not exist in the namespace "using:Y" 名称“ X”在名称空间“ clr-namespace:Y”中不存在 - The name “X” does not exist in the namespace “clr-namespace:Y” 命名空间“Y”中不存在类型或命名空间名称“X” - 在 VS 生成的代码中 - The type or namespace name 'X' does not exist in the namespace 'Y' - in VS generated code 命名空间中不存在类型或命名空间名称 - 但命名空间确实存在 - Type or namespace name does not exist in the namespace - yet the namespaces do exist 具有正确的名称空间和目录时,如何解决C#中的“类型名称不存在”错误 - How to fix 'The type name does not exist' error in C# while having the correct namespace and the directory 如何修复 gRPC 和 C# 的“命名空间名称“故障”的类型在命名空间中不存在”? - How to fix "The type of namespace name "Fault" does not exist in the namespace" for gRPC and C#? 是什么导致“名称空间中不存在类型或名称空间名称'UI'”错误? - What is causing “The type or namespace name 'UI' does not exist in the namespace” error? c#错误名称空间中不存在类型或名称空间名称'SampleMain' - c# error The type or namespace name 'SampleMain' does not exist in the namespace 命名空间中不存在类型或命名空间名称“Exchange” - The type or namespace name 'Exchange' does not exist in the namespace 类型或名称空间名称“ Confidence”在名称空间中不存在 - The type or namespace name 'Confidence' does not exist in the namespace
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM