views:

122

answers:

4

I'm getting a "type or namespace name could not be found" 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 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?

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?

+1  A: 

First I would verify that your project's generated information isn't corrupt. Do a clean and rebuild on your solution.

If that doesn't help, one thing I've seen work in the past for designer issues is opening up a windows forms project, then closing it again. This is a little chicken-entrails-ish, though, so don't hold your breath.

Greg D
I'd tried clean and rebuild on your solution but no luck. Tried removing/adding/cleaning/rebuilding just the WPF app project and still no luck too. :(
Greg
A: 

It may work to close and restart Visual Studio. It sometimes seems to get "Stuck"

Causas
have already tried this too - no luck :( Wondering if there is some project level config I can delete or something such that VS2010 would rebuild?
Greg
A: 

You might also try eliminating the code you think you're having problems with and seeing if it compiles with no references to that code. If not, fix things until it compiles again, and then work your suspected problem code back in. Sometimes I get strange errors about classes or methods that I know are correct when the compiler doesn't like something else. Once I fix the thing that it's really getting hung up on, these 'phantom' errors disappear.

Superstringcheese
thanks - still didn't help in this particular case :(
Greg
+4  A: 

I have seen this behaviour when an application is set to target the .Net 4 Client Profile framework, and the project it references targets the full .Net 4 framework.

The solution in this case is to either upgrade the framework target of the application, or downgrade the target of referenced assembly. I have not seen it mentioned explicitly anywhere, but from what i have seen 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).

slugster
excellent - this worked - I had to upgrade my WPF app client to use the full .NET Framework 4. Not sure what impact this will have on the client footprint? I did try downgrading the library I have to the .Net 4 Client Profile however when I did this it had similar issues with the recent Quartz.net 3rd party library I'd just started using. So it seems like using Quartz.net in my library project is ultimately forcing me to have to use the full .Net 4 framework in my UI WPF app.
Greg