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

笑着哭i 提交于 2019-12-25 08:47:54

问题


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?

[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.
  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 relay = new Framework.UserServices.RelayCommand(OpenEditor);


回答1:


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.



来源:https://stackoverflow.com/questions/10339521/how-do-i-fix-error-saying-the-type-or-namespace-name-x-does-not-exist-in-the-na

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!