I received a question today from one of my readers. (1 of the 10 I guess. LOL ) about VS2005 web projects.
I am trying to add some class code to my website project and it does not seem to want to recognize the namespace that I am using. When I create a namespace in my aspx files I can see them but not in my class files. What am I doing wrong?
This is a common mistake for those who are new to VS2005. Since you are now able to point to a folder on your drive and bring up a web project without setting up an IIS virtual directory, you need to do things a bit different. All class files need to be put in a special folder called App_Code. This folder will automatically be compiled at run time. You can use it to store .cs, .vb, xsd, wsdl etc..
The compiler will look to see what extension .cs or .vb your files have and use that languages compiler for C# or VB respectively. The code is then compiled into a single assembly and is made available to the code in your project. This means that you cannot have files of different languages inside this folder.
Or can you...?
By placing a <compilation><codeSubDirectory> set of tags in your web.config. The compiler will create separate assemblies for each folder. Of course, you have to put the files of like type into those folders.
Hope that helped.