No parameterless constructor defined for this object

Posted by Community Admin on 04-Aug-2018 21:49

No parameterless constructor defined for this object

All Replies

Posted by Community Admin on 28-May-2012 00:00

Hello,
I'm having some issues with a control that we have developed. The control is a general item selector for use in the back-end of sitefinity, specifically in custom modules. This selector is currently being used in one of our custom modules without any issues whatsoever. I attempted to re-use it in another custom module, and i ran into issues (When I say "Custom Module" I mean a module made base on the products module in the SDK, not a module made in the module builder). I get the following error after clicking on one of my items in my module from the listing in Sitefinity:

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) +98
   System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache) +241
   System.Activator.CreateInstance(Type type, Boolean nonPublic) +69
   Telerik.Sitefinity.Web.UI.FieldFactory.GetFieldControl(IFieldDefinition definition) +110
   Telerik.Sitefinity.Web.UI.ContentUI.Views.Backend.Detail.SectionControl.FieldsRepeater_ItemDataBound(Object sender, RepeaterItemEventArgs e) +258
   System.Web.UI.WebControls.Repeater.OnItemDataBound(RepeaterItemEventArgs e) +115
   System.Web.UI.WebControls.Repeater.CreateItem(Int32 itemIndex, ListItemType itemType, Boolean dataBind, Object dataItem) +138
   System.Web.UI.WebControls.Repeater.CreateControlHierarchy(Boolean useDataSource) +478
   System.Web.UI.WebControls.Repeater.OnDataBinding(EventArgs e) +61
   System.Web.UI.WebControls.Repeater.DataBind() +76
   System.Web.UI.Control.DataBindChildren() +201
   System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +101
   System.Web.UI.Control.DataBind() +15
   System.Web.UI.Control.DataBindChildren() +201
   System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +101
   System.Web.UI.Control.DataBind() +15
   System.Web.UI.Control.DataBindChildren() +201
   System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +101
   System.Web.UI.Control.DataBind() +15
   System.Web.UI.Control.DataBindChildren() +201
   System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +101
   System.Web.UI.Control.DataBind() +15
   System.Web.UI.Control.DataBindChildren() +201
   System.Web.UI.WebControls.CompositeControl.DataBind() +50
   System.Web.UI.Control.DataBindChildren() +201
   System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +101
   System.Web.UI.Control.DataBind() +15
   System.Web.UI.WebControls.Repeater.CreateItem(Int32 itemIndex, ListItemType itemType, Boolean dataBind, Object dataItem) +127
   System.Web.UI.WebControls.Repeater.CreateControlHierarchy(Boolean useDataSource) +478
   System.Web.UI.WebControls.Repeater.OnDataBinding(EventArgs e) +61
   System.Web.UI.WebControls.Repeater.DataBind() +76
   Telerik.Sitefinity.Web.UI.ContentUI.Views.Backend.Detail.DetailFormView.SetUpSections(IEnumerable`1 sections) +148
   Telerik.Sitefinity.Web.UI.ContentUI.Views.Backend.Detail.DetailFormView.OnPreRender(EventArgs e) +81
   System.Web.UI.Control.PreRenderRecursiveInternal() +103
   System.Web.UI.Control.PreRenderRecursiveInternal() +175
   System.Web.UI.Control.PreRenderRecursiveInternal() +175
   System.Web.UI.Control.PreRenderRecursiveInternal() +175
   System.Web.UI.Control.PreRenderRecursiveInternal() +175
   System.Web.UI.Control.PreRenderRecursiveInternal() +175
   System.Web.UI.Control.PreRenderRecursiveInternal() +175
   System.Web.UI.Control.PreRenderRecursiveInternal() +175
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2496

The request on which this exception is thrown looks like this:

~/Sitefinity/Dialog/ContentViewEditDialog?ControlDefinitionName=LocationsBackend&ViewName=LocationsBackendEdit

I've defined the reference to my control in my modules definitions file like so:

var doctorsField = new RelatedItemsElement(doctorsSection.Fields)
            
                ID = "doctorsField",
                DataFieldName = "Doctors",
                DisplayMode = displayMode,
                Title = "DoctorsToSetupFieldTitle",
                WrapperTag = HtmlTextWriterTag.Li,
                ResourceClassId = typeof(LocationsResources).Name,
                FieldType = typeof(RelatedItemsElement),
                RelatedItemDataServicePath = "~/Sitefinity/Services/DynamicModules/Data.svc/",
                RelatedItemType = "Telerik.Sitefinity.DynamicTypes.Model.DoctorBios.DoctorBio",
                SelectedItemsTemplate = @"<li><span data-bind='text: DoctorName'></span> <a href='#' class='remove'>Remove</a></li>",
                ListModeClientTemplate = @"<strong class='sfItemTitle'>DoctorName</strong>",
            ;
             
            doctorsSection.Fields.Add(doctorsField);

Has anyone run into a similar issue? I'd attach the control, but the attach file is locked to only images for the forum, so, I don't think I can do that. I'd just like to know what object its trying to find a parameterless contstructor for, at the very least.

This error ONLY occurs when I have this control in my definitions file. If I remove it, the form renders normally (albeit without this control.)

Does any one have any suggestions that might lead to correcting this issue? it seems quite strange since the code works fine in a different module. Any help would be greatly appreciated.

This thread is closed