You're using a Web Site Project, and this is one of the draws against them.
The thing to keep in mind with this project type is you are not compiling
your web site into a single dll, that's a Web Application Project. In the
Web Site Project you are creating dlls for files in the various directories.
The directories therefore have lots of dlls and are not compiled all at the
same time. So, your App_Code exists to avoid this by getting compiled first,
then you're able to use it in the other folders. Code in the other folders
gets compiled in a different order so that Folder B should be compiled
before Folder X. If you have code in Folder X that references a class in
Folder B, you'll be OK since it's already compiled. Try to reference code in
Folder X from Folder B and you'll get errors because Folder X is compiled
The easiest thing to do then with Web Site projects is to place all common
code in the App_Code directory. Alternateively, you can use the Web Site
Project which will just take all the code and compile it ino a single dll
for the project. This was the original project type for Visual Studio, but
in VS 2005 was replaced by the web site project. After much outcry it was
made available again as an add-in, then rolled into VS 2005 Service Pack 1.
If you have VS 2005 SP1 you'll have this project type under New | Projects |
language choice (C# or VB) | Web | Web Application Project. The only
drawback is the membership profile provider needs an add-in in order to
generate the necessary classes to support any profile definitions you have
in the membership user profile definition in the web.config.
Hope this helps,
"Centron System Solutions" <DGleeson3@xxxxxx> wrote in message
> Hello all
> Im using ASP.Net VS2005
> I want to craete a directory structure for my new Website project.
> If I put classes inside "APP_Code" folder I have no problem accessing
> that code from code behind files.
> However if I create any other folder and put a class inside I get the
> following type of build error
> "The Type or namespace name 'Class2' could not be found (are you
> missing a using directive......)"
> What are the mechanics of creating a directory structure and allowing
> the code there in to be used in code behind files?
> Thanks for any help in advance.