I am trying to modify an existing .net "website" project by adding a new class to it. I added my class inside the App_Code folder (let's call this class "ClassA"), and tried to access it from the outside in an aspx.cs file. For some reason, right after I created the class, I can create an instance of it in my aspx.cs file without any warnings from Visual Studio (e.g., ClassA a = new ClassA()). But every time I rebuild the project, I get the following Error from visual studio (The type or namespace name 'ClassA' could not be found (are you missing a using directive or an assembly reference?)). What am I missing here?
Code for Class A -> App_Code/ClassA.cs
public class ClassA
{
public string test;
}
Code for Test.aspx.cs
namespace A{
public class Test : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
ClassA a = new ClassA(); // line with error
}
}
}
If I put everything in Test.aspx.cs I get no errors:
namespace A{
public class ClassA
{
public string test;
}
public class Test : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
ClassA a = new ClassA(); // no error!
}
}
}