I have a situation where T4MVC generates everything correctly (this means that intellisense displays all areas / controllers / actions and compiles everything), but when I run the code, I get a runtime error T4MVC was called incorrectly.
I examined the generated files and found that for a single controller in my project, only actions in the base class receive generated overridden stub actions. For other controllers, all actions are generated. They all have the same setting, described below.
I have a class BaseControllerthat has common code (and inherits from Controller). In the directory Controllers(project root), I have several controllers that inherit from BaseController.
Then I have several areas. In each Region, I have the same controllers, each of which is inherited from a controller with the same name in the root directory of the controllers.
Running T4MVC (version 2.6.54), everything works fine, except for controller one . It is strange that intellisense works for the controller, but is throttled when the actual action is referenced (in a call ActionLink()).
I manually added one action, in particular, to the generated code, and there were no errors.
So my question is: what can cause T4MVC not to generate all the code for the controller? Missed actions are everything public virtual ActionResult, and the actions themselves work fine. The problem controller has the same problem in all areas.
Some abbreviated codes.
/Controllers/BaseController.cs
namespace MyProject.Controllers
{
public abstract partial class BaseController : Controller
{
protected ISession session;
public BaseController()
{
}
}
}
/Controllers/ActivitiesController.cs( )
namespace MyProject.Controllers
{
public partial class ActivitiesController : BaseController
{
private Activity userValues;
private Activity databaseValues;
public ActivitiesController() : base()
{
ViewBag.ControllerName = "Activities";
}
<li>@Html.ActionLink("Activities", MVC.Areas.Module1.Activities.Index())</li> in a view
public virtual ActionResult Index()
{
return View();
}
}
}
/Areas/Module1/Controllers/ActivitiesController.cs.
namespace MyProject.Areas.Module1.Controllers
{
public partial class ActivitiesController : MyProject.Controllers.ActivitiesController
{
public ActivitiesController() : base()
{
base.currentModule = Modules.Module1;
}
}
}