NullReferenceException when calling Html.Action (Self answer)
One of our developers was seeing the following exception whenever Html.Action was getting called:
[NullReferenceException: Object reference not set to an instance of an object.]
Telerik.Sitefinity.Mvc.SitefinityMvcRoute.GetOrderedParameters(RouteValueDictionary values, Type controllerType) +311
Telerik.Sitefinity.Mvc.SitefinityMvcRoute.GenerateVirtualPath(RouteValueDictionary values, RequestContext requestContext) +453
Telerik.Sitefinity.Mvc.SitefinityMvcRoute.GetVirtualPath(RequestContext requestContext, RouteValueDictionary values) +262
System.Web.Routing.RouteCollection.GetVirtualPath(RequestContext requestContext, RouteValueDictionary values) +96
System.Web.Mvc.RouteCollectionExtensions.GetVirtualPathForArea(RouteCollection routes, RequestContext requestContext, String name, RouteValueDictionary values, Boolean& usingAreas) +257
System.Web.Mvc.Html.ChildActionExtensions.ActionHelper(HtmlHelper htmlHelper, String actionName, String controllerName, RouteValueDictionary routeValues, TextWriter textWriter) +221
System.Web.Mvc.Html.ChildActionExtensions.Action(HtmlHelper htmlHelper, String actionName, String controllerName, RouteValueDictionary routeValues) +83
System.Web.Mvc.Html.ChildActionExtensions.Action(HtmlHelper htmlHelper, String actionName, String controllerName, Object routeValues) +45
When we debugged the code, it ended up being because SitefinityMvcRoute could not resolve a controller type by its name.
After looking in the Sitefinity error log, we saw an additional error that we thought was odd:
Access to the path 'C:\Plastic\MyProject\App_Data\Sitefinity\Configuration\ToolboxesConfig.config' is denied.
We discovered that the ToolboxesConfig.config file was being set to read-only by Plastic SCM and this was causing that error. When we changed the Plastic SCM configuration so that it would not set files to read-only, both errors were resolved. Html.Action worked correctly.