So I wrote some custom classes and put them all in a namespace, call it "Sphere".

On my aspx.cs codebehind file, I have "using Sphere;" written. I know that this works because it's always worked until I copied this project to a new folder. Also, even when I click "view in web browser" everything works perfectly.

Simply, Visual Studio 08 is not recognizing the namespace and so I cannot build without an error and consequently cannot debug. Thanks for the help!

edit: I have my namespace in my App_Code folder in a .cs file

No correct solution


Are your custom classes in a separate project? If so, you might need to add a reference to that project. If you have copied the project to a new folder, the path to your Sphere DLL/project in VS2008 might be broken.

I actually just figured it out:

My .cs files were set to "build action: content" rather than "compile." I right-clicked + properties all my files and changed the build action, and now it all works!

Sounds like missing reference.

In your new project, do you have a reference to the project that defines the actual Sphere namespace?

Check your references. It's possible VS is no longer finding them after you moved your application's folder.

It sounds like when you moved the files the references were broken. If the sphere classes are in a seperate dll try deleting and re-adding the reference. If it is just in a .de file be sure that filein the project is still in the relative path.

Probably you got this error:

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

And the reason the type was not in the assembly is that App_Code folder is specific folder for Web Site Projects. These files get compiled at runtime when they are deployed on server and not when you are building the project. In Web Application Project every file has Build Action property. By default the classes files have value of Compile. But if the class is created in App_Code file it gets value Content. and does not get compiled when running as Application.
A the end the App_Code folder is not meant to be used in Web Application. Or as you figured it out you can manually change the Build Action to Compile.

I found the answer by searching these links:

  1. Vishal Joshi's Tangent - App_Code folder doesn’t work with Web Application Projects (WAPs)
  2. Build Action" property set to "Content" for class files inside App_Code folder
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow