Class Added to App_Code folder not accessible

August 4, 2009

Ok, I’ll get straight to the pont on this one. I’ve been trying to add a new class to a project within Visual Studio, but have found the class to be inaccessible to Visual Studio, i.e. No intellisense and the project would not compile.

After much posting and discussion, I discovered that the problem was due to the fact that I was using the App_Code folder to store my class files (.cs) within a project created with the ‘Web Application Project’ template.

It seems Visual Studio is only happy for us developers to make use of the (recommended) App_Code folder within a project created with the ‘Website Project’ template.

Just to clarify:

  • Web Application Project – A class added to the App_Code folder is NOT accessible/usable.
    (Classes added to the root of the project are O I’ve not tried adding to a sub-folder)
  • Website Project – A class added to the App_Code folder IS accessible/usable, also worth noting that adding a new class to a website project, results in a prompt to store it in the App_Code folder (Which is created if it does not exist)

I’ve tried this on two machines, both running Visual Studio 2008 Professional with SP1

If you have any idea for the reasoning behind this behaviour, please leave a comment and let me know!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: