Feedback
 
Did this article resolve your question/issue?

   

Your feedback is appreciated.

Please tell us how we can make this article more useful. Please provide us a way to contact you, should we need clarification on the feedback provided or if you need further assistance.

Characters Remaining: 1025

 


Article

"No parameterless constructor defined for this object." exception after Feather upgrade when using Sitefinity

« Go Back

Information

 
Article Number000071739
EnvironmentProduct: Sitefinity
Version: 8.2, 9.x, 10.x
OS: All supported OS versions
Database: All supported Microsoft SQL Server versions
Question/Problem Description
"No parameterless constructor defined for this object." exception is received after upgrade of Feather to version 1.4.410.0. The exception is thrown on all frontend pages that use Feather widgets.
 
No parameterless constructor defined for this object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.MissingMethodException: No parameterless constructor defined for this object.

Source Error: 


An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:

[MissingMethodException: No parameterless constructor defined for this object.]
   System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0
   System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) +119
   System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) +232
   System.Activator.CreateInstance(Type type, Boolean nonPublic) +83
   System.Activator.CreateInstance(Type type) +11
   Telerik.Sitefinity.Frontend.Mvc.Infrastructure.Controllers.ControllerExtensions.BuildViewEngineCollection(IList`1 pathTransformations) +289
   Telerik.Sitefinity.Frontend.Mvc.Infrastructure.Controllers.ControllerExtensions.GetViewEngineCollection(Controller controller, Func`1 pathTransformationsFunc) +146
   Telerik.Sitefinity.Frontend.Mvc.Infrastructure.Controllers.ControllerExtensions.UpdateViewEnginesCollection(Controller controller, Func`1 pathTransformationsFunc) +21
   Telerik.Sitefinity.Frontend.Mvc.Infrastructure.Controllers.FrontendControllerFactory.EnhanceViewEngines(Controller controller) +101
   Telerik.Sitefinity.Frontend.Mvc.Infrastructure.Controllers.FrontendControllerFactory.CreateController(RequestContext requestContext, String controllerName) +38
   Telerik.Sitefinity.Mvc.Proxy.MvcControllerProxy.get_Controller() +93
   Telerik.Sitefinity.Mvc.Proxy.MvcControllerProxy.get_Settings() +332
   Telerik.Sitefinity.Abstractions.VirtualPath.PageResolverBase.AppendProperties(StringBuilder output, ObjectData ctrlData, Type ctrlType, CursorCollection placeHolders, PageTemplateFramework framework) +499
   Telerik.Sitefinity.Abstractions.VirtualPath.PageResolverBase.RenderControl(PageData pageData, StringBuilder output, CursorCollection placeHolders, ControlData ctrlData, Type ctrlType, Boolean& needsWrapper, String& securedObjectTagName) +489
   Telerik.Sitefinity.Abstractions.VirtualPath.PageResolverBase.BuildControls(PageData pageData, List`1 controlConatiners, CursorCollection placeHolders, DirectiveCollection directives) +1430
   Telerik.Sitefinity.Abstractions.VirtualPath.SitefinityPageResolver.RenderPage(StringBuilder output, PageData pageData, RequestContext context, String virtualPath) +152

 
Steps to Reproduce1. Upgrade Feather
2. Do not choose to remove the RazorGeneratorMvcStart.cs from App_Start
3. Build the project
Clarifying Information
Error MessageNo parameterless constructor defined for this object.
Defect/Enhancement Number
Cause
The exception is caused by the RazorGeneratorMvcStart class which includes the PrecompiledMvcEngine view engine. This view engine does not have a parameterless constructor, which results in the exception.
Resolution

Using Feather

If Feather is enabled and used, the RazorGeneratorMvcStart could be removed, since the precompilation will be done by a ViewEngine integrated in Feather.

The PrecompiledMvcEngine is not concerning the precompilation done by Feather.
Sitefinity Documentation, View Precompilation https://www.progress.com/documentation/sitefinity-cms/view-precompilation-mvc

Not Using Feather

If MVC widgets are used without Feather, the PrecompiledMvcEngine could be used to precompile the MVC widgets' views.

In order to use it, wrapped it in a class that has a parameterless constructor:

public static class RazorGeneratorMvcStart
{
    public static void Start()
    {
        var engine = new PrecompiledMvcEngineCustom()
        {
            UsePhysicalViewsIfNewer = HttpContext.Current.Request.IsLocal,
        };

        ViewEngines.Engines.Insert(0, engine);

        // StartPage lookups are done by WebPages.
        VirtualPathFactoryManager.RegisterVirtualPathFactory(engine);
    }
}

public class PrecompiledMvcEngineCustom : PrecompiledMvcEngine
{
    public PrecompiledMvcEngineCustom()
        : base(typeof(RazorGeneratorMvcStart).Assembly)
    {
    }
}

The RazorGeneratorMvcStart will now register the custom View Engine. This way the widget Views can be precompiled. More information on this can be found in the RazorGenerator: GitHub, RazorGenerator https://github.com/RazorGenerator/RazorGenerator
Workaround
Notes
Attachment 
Last Modified Date1/8/2019 12:34 PM