I have moved what was a C# ASP Web Site over to be a C# ASP Web Application. I did this so I can do things like add Pre-Build events.
Everything seems to be nearly working correctly except some namespaces which I have declared in .cs files in my App_Code folder are not being recognised.
I get build errors such as
The type or namespace name 'nsAppGlobal' could not be found (are you missing a using directive or an assembly reference?)
I have a .cs file which quite clearly declares this namespace. For some reason Intellisense and the compiler both can’t see it.
I have heard that I can solve this problem by building my namespace into a dll library and then including that in the web-application. This sounds pretty silly – because how then would I edit that code? I would have to edit in another project and rebuild the dll?
Has anyone encountered this problem? What is the best strategy for using namespaces in web application projects?
I noticed this behavior, too, when migrating a web site to a web application: it seems the App_Code directory is ignored due to its “magical” name.
The solution was easy: simply rename the App_Code directory.