We are developing a web application with ASP.Net 4 and MVC 3 Framework. I installed T4MVC via NuGet and all views, controllers and static content were successfully generated as strong types.
But when I try to compile the project, it causes an error with the generated T4MVC.cs file, which:
'T4MVC_ViewResultBase.FindView(System.Web.Mvc.ControllerContext)':
return type must be 'System.Web.Mvc.ViewEngineResult' to match overridden member
'System.Web.Mvc.ViewResultBase.FindView(System.Web.Mvc.ControllerContext)'
This is the source code:
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public class T4MVC_ViewResultBase : System.Web.Mvc.ViewResultBase,
IT4MVCActionResult
{
public T4MVC_ViewResultBase(string area, string controller, string action):
base() {
this.InitMVCT4Result(area, controller, action);
}
protected override void FindView(System.Web.Mvc.ControllerContext context){}
public string Controller { get; set; }
public string Action { get; set; }
public RouteValueDictionary RouteValueDictionary { get; set; }
}
The error says that:
protected override void FindView(System.Web.Mvc.ControllerContext context) { }
it should be:
protected override ViewEngineResult
FindView(System.Web.Mvc.ControllerContext context) { }
But then another compilation error occurs, since this method should return code.
If we check the base class that it inherits, System.Web.Mvc.ViewResultBase, it actually declares FindView () with the return type ViewEngineResult:
public abstract class ViewResultBase : ActionResult
{
...
protected abstract ViewEngineResult FindView(ControllerContext context);
}
Has anyone got this error? Is this something related to the MVC version, are we using MVC 3?
Thank you so much! Sergi