Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

No parameterless constructor defined for this object. #459


User avatar
0
eravse created

Hi all , I never encountered a problem with my development machine, but when the server running under IIS its craching. I checked my IIS settings but i dont found any interesting things.

Please help me how i fix it.

I am getting error like this ;

Server Error in '/' Application.

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:

Line 47: <body class="corporate"> Line 48: Line 49: @Html.Action("Header", "Layout", new { currentPageName = ViewBag.CurrentPageName }) Line 50: Line 51: <div class="main">

Source File: c:\WebSites\abc.demosites.com\Views\Layout_Layout.cshtml Line: 49

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) +113 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) +66 System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +55

[InvalidOperationException: An error occurred when trying to create a controller of type 'Demosites.DemoCompany.Web.Controllers.LayoutController'. Make sure that the controller has a parameterless public constructor.] System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +178

.....


3 Answer(s)
  • User Avatar
    0
    hikalkan created
    Support Team

    Your application seems not using dependency injection for controllers. Have you added [DependsOn(typeof(AbpWebMvcModule))] to your WebModule (it's like that in startup templates)?

  • User Avatar
    0
    eravse created

    No i havent yet when i get last update it is only like this, [DependsOn( typeof(DemoDataModule), typeof(DemoApplicationModule), typeof(DemoWebApiModule))]

    i will add typeof(AbpWebMvcModule) and try again leter i write result. thanks

  • User Avatar
    0
    eravse created

    Its return to normal. thanks Hikalkan.