The type or namespace 'MyNameSpace' does not exist in the namespace 'MyProject' error and possible fixes

by Heathesh 3. November 2010 06:51

While working with Visual Studio 2010 (VS2010) I created a solution with multiple projects in it. Each of the projects would build except my Windows Application / Console application and I was getting a very annoying error:

The type or namespace 'MyNameSpace' does not exist in the namespace 'MyProject' (are you missing an assembly reference?)

I could not understand why this was happening because every single one of my projects would build individually except the Windows Application / Console Application. Luckily I noticed there was a warning message stating:

The referenced assembly " [insert assembly path here] " could not be resolved because it has a dependency on "System.Web, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which is not in the currently targeted framework ".NETFramework,Version=v4.0,Profile=Client". Please remove references to assemblies not in the targeted framework or consider retargeting your project.

The root problem of this error is simple, your target framework is ".NETFramework,Version=v4.0,Profile=Client", specifically you're targetting the "Client" profile and one of your other projects references System.Web. The Client profile does not include any ASP.Net features and one of your projects must be referencing System.Web - and that is the cause of the error. To see more about the Client Profile please visit this MSDN page: .NET Framework Client Profile

In order to fix this, you just have to change the target framework of your application to ".NET Framework 4", and not ".NET Framework 4 Client Profile". You can do this by:

  1. Right click the Windows Application / Console Application project in your solution explorer window, and select "Properties"
  2. Select the "Application" tab
  3. You should see a drop down under the heading "Target framework", if it currently says ".NET Framework 4 Client Profile" then you've gotten the error for the same reason I got it, and you simple need to change this to ".NET Framework 4"
  4. Build your project again, and it should work!

Happy building!

Powered by BlogEngine.NET (with enhancements by Heathesh)
Theme by Mads Kristensen (with tweeks by Heathesh)


Microsoft Certified Professional

Microsoft Certified Technology Specialist

Answer Questions


Tag cloud


<<  September 2017  >>

View posts in large calendar