Search code examples
c#asp.net-mvcprojects

After creating separate Models and Controllers projects, I get "no suitable method found to override" on my Initialize method declaration


This is driving me insane... I am reorganizing my MVC app into a Models project and a Controllers project, and then the main application as a project. So, everything is working good so far except...

Whenever I go to "Rebuild" my controllers project, I get this error:

Controllers.AccountController.Initialize(System.Web.Routing.RequestContext)': no suitable method found to override.

Keep in mind that AccountController.cs was automatically placed in my application by Visual Studio, and this was all working fine when the Controllers were within my main project. I think it might have to do with the ASPNETDB.MDF file that this AccountController.cs file references to authenticate users as they log in, since this database stayed within my main project and didn't follow the Controllers project. Thoughts on that??

Here's the Initialize method on my AccountController:

        protected override void Initialize(RequestContext requestContext)
    {
        if (FormsService == null) { FormsService = new FormsAuthenticationService(); }
        if (MembershipService == null) { MembershipService = new AccountMembershipService(); }

        base.Initialize(requestContext);
    }

PLEASE HELP!!! Thanks in advance!!


Solution

  • It turns out what I was missing was a reference to System.Web.Routing. I had using System.Web.Routing, and it wasn't marked "red" (meaning, it couldn't find it), so I just assumed it was there. So this fixed the problem.