Showing posts with label type or namespace name could not be found. Show all posts
Showing posts with label type or namespace name could not be found. Show all posts

Thursday, August 11, 2011

Little Gotcha in VS 2010

If you have a class library, and you want to write a Console app to test your class lib with, you might find you get a compile error that doesn't make sense:

The type or namespace name 'MyClassLib' could not be found (are you missing a using directive or an assembly reference?) 

This could be caused by the target framework being set to "client"

Here's how to fix it:
  1. Right click the console app project, and select Properties (at the bottom of the menu).
  2. Select the Application tab on the Property page
  3. Check the Target Framework - make sure it is NOT .Net Framework 4.0 (or 3.5, if that's what you are using).
  4. If it is client, you can just select the correct framework - in my case .Net Framework 4.0
  5. When you select the new Framework, you will get a warning about unloading the project.  Who cares, it's wrong anyway!  :-)