C# – asp.NET 2.0 Web Site Can’t Access Classes in App_Code

asp.netcweb

I'm having a problem accessing a class after deploying my website to a server.
Note that this is a Web Site not Web Application.The error is:

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

Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433

I've done a lot of googling and haven't been able to find anything that helps.

My code looks like this (I get the compiler error on the line declaring Order):

//Default.aspx.cs
namespace Foo
{
    public partial class _Default : System.Web.UI.Page
    {
        private Order custOrder;
        ....etc
    }
}

In the App_Code folder I have Order.cs:

namespace Foo
{
    public class Order
    {
        ....etc
    }
}

The strange thing is that this works fine locally and in a dev environment. When I move it to a qa environment, that's when I get that error.

I deploy by committing all the code to a subversion repository and then doing an export on the server machines.

I guess it could be some kind of namespace error, but I don't know why it would work on some machines and not others.

Any idea what could be different on a different server that might cause this? All machines report the .net version as 2.0

Best Answer

Right click the source file in App_Code and set its "Build Action" property to "Compile".