Feedback
Did this article resolve your question/issue?

   

Article

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

« Go Back

Information

 
Title"No parameterless constructor defined for this object." exception after Feather upgrade when using Sitefinity
URL NameNo-parameterless-constructor-defined-for-this-object-exception-after-Feather-upgrade
Article Number000187120
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 Number
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
Last Modified Date1/8/2019 12:34 PM
Attachment 
Files
Disclaimer The origins of the information on this site may be internal or external to Progress Software Corporation (“Progress”). Progress Software Corporation makes all reasonable efforts to verify this information. However, the information provided is for your information only. Progress Software Corporation makes no explicit or implied claims to the validity of this information.

Any sample code provided on this site is not supported under any Progress support program or service. The sample code is provided on an "AS IS" basis. Progress makes no warranties, express or implied, and disclaims all implied warranties including, without limitation, the implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample code is borne by the user. In no event shall Progress, its employees, or anyone else involved in the creation, production, or delivery of the code be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample code, even if Progress has been advised of the possibility of such damages.