Abe Miessler
Abe Miessler

Reputation: 85036

Class could not be found?

I have a asp.net Web Site Project that I am migrating to a Web Application Project. Most of the forms in this project are derived from a base class, but for some reason after the migration, the base class is not being found. My base class is in the following folder: App_Code/BaseClasses/BasePage.cs and is defined as follows:

//more stuff above
using System.Web;

public class BasePage : Page
{
    public BasePage()
    {
    }
    protected override void OnInit(EventArgs e)
    {
       //whatever
    }
    //some other stuff
}

And my forms are in a variety of folder and they use the base class like so:

//More stuff above
using System.Web;
                                       //Derived from base page
public partial class Reports_Uploads : BasePage
{
    //a bunch of stuff
}

Any time I try to derive from the base page I get the following error:

Error 166 The type or namespace name 'BasePage' could not be found (are you missing a using directive or an assembly reference?)

I tried wrapping both in the same namespace, but that didn't make any difference. There are not any errors on BasePage when I attempt to compile. Can anyone see why this would be happening?

Upvotes: 1

Views: 2801

Answers (2)

Abe Miessler
Abe Miessler

Reputation: 85036

Ok - it looks like I needed to do a "Convert to Web Application" on the entire project in order to get my base class recognized. A lot of the older instructions that I've seen say to right click on the project and click "Convert to Web Applicaiton", but that was not an option using Visual Studio 2013. I had to:

  1. Select the project I wanted to convert
  2. In the top menu items I had to select Project -> Convert to Web Application

Once I did that, it changed my App_Code folder to Old_App_Code and then the base class was recognized everywhere. I didn't need to add namespaces or anything.

Hope this helps someone!

Upvotes: 2

fraser jordan
fraser jordan

Reputation: 114

Try adding a using statement at the beginning, like the using System.Web line.

maybe try the following:

using App_Code.BaseClasses.BasePage; (NOTE: this may change depending on your file structure)

Upvotes: 0

Related Questions