[Mono-aspnet-list] Can't access class in App_Code from code behind

don rhummy donrhummy at yahoo.com
Mon Jan 7 23:46:57 UTC 2013

Neither. I'm just using jEdit and coding the files myself. Is there some way to compile the .cs file myself?

 From: Daniel Lo Nigro <lists at dan.cx>
To: don rhummy <donrhummy at yahoo.com> 
Cc: "mono-aspnet-list at lists.ximian.com" <mono-aspnet-list at lists.ximian.com> 
Sent: Monday, January 7, 2013 5:35 PM
Subject: Re: [Mono-aspnet-list] Can't access class in App_Code from code behind

Are you using a Web Application project or a Web Site Project?

Web Application projects need to be precompiled - You should have a .csproj (Visual Studio / MonoDevelop C# project) file that should be compiled before deployment.

On Tue, Jan 8, 2013 at 9:09 AM, don rhummy <donrhummy at yahoo.com> wrote:

I have a class in a file "MYClass.cs" that's in the "App_Code" folder. I'm able to use this in an "aspx" file but not from a code-behind file. How do I make it visible to a code-behind?
>My files:
>ASPX FILE (testappcode.aspx)
><%@ Page language="c#" src="TestAppCode.aspx.cs" Inherits="TestAppCode.TestAppCode" AutoEventWireup="true" %>
>  <head>
>    <title>Test App_Code Folder</title>
>  </head>
>  <body>
>    <form id="contactForm" runat="server">
>        <asp:TextBox id="Name" runat="server" ></asp:TextBox>
>        <asp:TextBox id="Age" runat="server"
>        <asp:Button ID="Submit" runat="server" Text="Submit" onclick="SubmitForm" />
>    </form>
>  </body>
>CODE BEHIND (TestAppCode.aspx.cs)
>using System;
>using System.Web.UI.WebControls;
>namespace TestAppCode
>    public class TestAppCode : System.Web.UI.Page
>    {
>        protected void SubmitForm(object sender, EventArgs e)
>        {
>            //It fails here with the error: CS0246: The type or namespace name
>            //`MyAppCodeClass' could not be found. Are you missing a using 
>            //directive or
 an assembly reference?
>            MyAppCodeClass m = new MyAppCodeClass();
>        }
>    }
>APP_CODE CLASS (App_Code/MyAppCodeClass.cs)
>public class MyAppCodeClass
>         public MyAppCodeClass() {}
>Mono-aspnet-list mailing list
>Mono-aspnet-list at lists.ximian.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-aspnet-list/attachments/20130107/2bc2341f/attachment-0001.html>

More information about the Mono-aspnet-list mailing list