问题
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.
- Added reference to project Framework.UserServices.
- Verified Relay Command type existed in Object Browser with namespace of Framework.UserServices.
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