PC Review


Reply
Thread Tools Rate Thread

App_Code class access confusion

 
 
rlm
Guest
Posts: n/a
 
      16th Jan 2008
Steps to reproduce:
1. Create new web app. I am in v3.5 and vs2008
2. Create App_Code folder
3. Add Class A with public static int B;
4. Go to default.aspx.cs Page_Load and the compiler says that Class A does
not exist in the current context.

Why? And how do I access these classes in App_Code?

By default it creates the namespace for the class as
WebApplication1.App_Code, but htis doesn't seem to matter. I change the
namespace or remove it, nothing works.

I have another starter kit that has App_Code classes which are recognized
fine, but I don't know why.
 
Reply With Quote
 
 
 
 
Peter Bromberg [C# MVP]
Guest
Posts: n/a
 
      16th Jan 2008
I believe the APP_CODE folder is only used in the Web Site project model,
not in the Web Application Project. Just add the class to the project at the
same level as the aspx pages, or compile it to a separate class library app
and set a reference to it.
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
MetaFinder: http://www.blogmetafinder.com


"rlm" wrote:

> Steps to reproduce:
> 1. Create new web app. I am in v3.5 and vs2008
> 2. Create App_Code folder
> 3. Add Class A with public static int B;
> 4. Go to default.aspx.cs Page_Load and the compiler says that Class A does
> not exist in the current context.
>
> Why? And how do I access these classes in App_Code?
>
> By default it creates the namespace for the class as
> WebApplication1.App_Code, but htis doesn't seem to matter. I change the
> namespace or remove it, nothing works.
>
> I have another starter kit that has App_Code classes which are recognized
> fine, but I don't know why.

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot find data access class file in App_Code folder Alex. O. Koranteng Microsoft ASP .NET 7 9th Jun 2009 01:22 AM
Confusion about Namespaces and App_Code, etc. in VS2008/ASP.net3.5 Alex Maghen Microsoft ASP .NET 2 25th Dec 2008 02:49 AM
Access Session State From Class File in App_Code Joey Microsoft ASP .NET 2 25th Jun 2007 09:40 PM
Calling Class from App_Code using vb sck10 Microsoft ASP .NET 5 18th Aug 2006 01:35 AM
How do I access MasterPage functionality from an App_Code class? dawg1998 Microsoft ASP .NET 2 22nd Feb 2006 07:43 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:04 PM.