Groups | Blog | Home
all groups > inetserver asp general > july 2007 >

inetserver asp general : putting C# classes in App_Code



accessing C# classes in App_Code
7/24/2007 1:54:02 PM
I've a simple aspx page whose code behind instantiates a simple class which
exists in a .cs file in the App_Code folder of my project. Runs fine in the
IDE. When I copy the app to my IIS server I get this error in my browser:

Compilation Error
Description: An error occurred during the compilation of a resource required
to service this request. Please review the following specific error details
and modify your source code appropriately.

Compiler Error Message: CS0246: The type or namespace name 'CustomClass'
could not be found (are you missing a using directive or an assembly
reference?)

Source Error:
Line 18: protected void Button1_Click(object sender, EventArgs e)
Line 19: {
Line 20: CustomClass c = new CustomClass();
Line 21: Label1.Text = c.GetMessage(TextBox1.Text);
Line 22: }

Source File: c:\Inetpub\wwwroot\AppCode_test\Default.aspx.cs Line: 20

What's up?

LRuss
7/24/2007 2:36:01 PM
Thanks for pointing this out Bob. I found the solution to my problem; the
App_Code folder must sit in the site root, not in the virtual directory.

Len

[quoted text, click to view]
LRuss
7/24/2007 2:38:01 PM
BTW Bob, do you know where the ASP.NET newsgroup is on MSN?

[quoted text, click to view]
Bob Barrows [MVP]
7/24/2007 5:06:54 PM
[quoted text, click to view]

There was no way for you to know it (except maybe by browsing through some
of the previous questions in this newsgroup before posting yours - always a
recommended practice) , but this is a classic asp newsgroup. ASP.Net bears
very little resemblance to classic ASP so, while you may be lucky enough to
find a dotnet-knowledgeable person here who can answer your question, you
can eliminate the luck factor by posting your question to a group where
those dotnet-knowledgeable people hang out. I suggest
microsoft.public.dotnet.framework.aspnet.
There are also forums at www.asp.net
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"

Jon Paal [MSMD]
7/25/2007 6:22:07 AM
look here:

microsoft.public.dotnet.framework.aspnet

AddThis Social Bookmark Button