No parameterless constructor defined for this object

2 posts, 0 answers
  1. Rasika
    Rasika avatar
    3 posts
    Member since:
    Jul 2012

    Posted 18 Jul 2012 Link to this post

    Hi

     We are getting the error  "No parameterless constructor defined for this object" when we try to bind collection to the Kendo grid and obviously the business objects that we have in our business layer has private constructors and it worked fine with Telerik. 

    Here is the stack trace of the error 

    Line 171:    {
    Line 172:        //@(Html.Kendo().Grid<City.Australia.Framework.BL.UserInfo>()
    Line 173:        @(Html.Kendo().Grid(Model.Users)
    Line 174:            .Name("UserGrid")
    Line 175:            .EnableCustomBinding(true)


    Source File: d:\Development\City.Australia.Admin\City.Australia.Admin\Views\User\Search.cshtml    Line: 173 

    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) +98
       System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache) +241
       System.Activator.CreateInstance(Type type, Boolean nonPublic) +69
       Kendo.Mvc.UI.ModelDescriptor.CreateDataItem(Type modelType) +131
       Kendo.Mvc.UI.ModelDescriptor..ctor(Type modelType) +40
       Kendo.Mvc.UI.DataSource.ModelType(Type modelType) +31
       Kendo.Mvc.UI.Grid`1..ctor(ViewContext viewContext, IJavaScriptInitializer initializer, IUrlGenerator urlGenerator, IGridHtmlBuilderFactory htmlBuilderFactory) +822
       Kendo.Mvc.UI.Fluent.WidgetFactory.Grid() +114
       Kendo.Mvc.UI.Fluent.WidgetFactory.Grid(IEnumerable`1 dataSource) +55
       ASP._Page_Views_User_Search_cshtml.Execute() in d:\Development\City.Australia.Admin\City.Australia.Admin\Views\User\Search.cshtml:173
       System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +207
       System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +81
       System.Web.WebPages.StartPage.RunPage() +19
       System.Web.WebPages.StartPage.ExecutePageHierarchy() +65
       System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +76
       System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +220
       System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +115
       System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +303
       System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +13
       System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +23
       System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +260
       System.Web.Mvc.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b() +19
       System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +177
       System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +343
       System.Web.Mvc.Controller.ExecuteCore() +116
       System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +97
       System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10
       System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +37
       System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +21
       System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +12
       System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
       System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +50
       System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7
       System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22
       System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60
       System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
       System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8969117
       System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184

    Thanks
    Rasika Perera 
  2. Rasika
    Rasika avatar
    3 posts
    Member since:
    Jul 2012

    Posted 18 Jul 2012 Link to this post

    Got a reply for the support ticket that was raised

    I'm afraid that having a parameterless constructor is required in current version of KendoUI for ASP.Net MVC Grid widget. This is due to the way fields metadata is extracted from the specified model type.

    Greetings,
    Rosen 
    the Telerik team 
  3. UI for ASP.NET MVC is VS 2017 Ready
Back to Top