1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Cannot create an instance of Telerik.Sitefinity.Web.UI.ContentUI.Config.ContentViewDefinitionElement because it is an abstract class.

Cannot create an instance of Telerik.Sitefinity.Web.UI.ContentUI.Config.ContentViewDefinitionElement because it is an abstract class.

5 posts, 0 answered
  1. AJ
    AJ avatar
    11 posts
    Registered:
    17 Sep 2012
    13 Jul 2012
    Link to this post
    I've created a pluggable module based on the example Jobs module. I installed it and it worked fine. I then added an extra field to it and as soon as I try and access the content area I get the message  below. Any idea what is going wrong?


    Server Error in '/' Application.
     
    Cannot create an instance of Telerik.Sitefinity.Web.UI.ContentUI.Config.ContentViewDefinitionElement because it is an abstract class.
     
    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.MemberAccessException: Cannot create an instance of Telerik.Sitefinity.Web.UI.ContentUI.Config.ContentViewDefinitionElement because it is an abstract class.
     
    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:
     
     
    [MemberAccessException: Cannot create an instance of Telerik.Sitefinity.Web.UI.ContentUI.Config.ContentViewDefinitionElement because it is an abstract class.]
       System.Reflection.RuntimeConstructorInfo.CheckCanCreateInstance(Type declaringType, Boolean isVarArg) +9587582
       System.Reflection.RuntimeConstructorInfo.ThrowNoInvokeException() +56
       System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +9637248
       System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +1136
       System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +111
       System.Activator.CreateInstance(Type type, Object[] args) +19
       Telerik.Sitefinity.Configuration.ConfigUtils.CreateInstance(Type baseType, Type actualType, Object[] args) +236
       Telerik.Sitefinity.Configuration.ConfigUtils.CreateInstance(Type actualType, Object[] args) +103
       Telerik.Sitefinity.Configuration.ConfigElementDictionary`2.CreateNew(Type type) +132
       Telerik.Sitefinity.Configuration.Data.XmlConfigProvider.LoadCollectionElement(ConfigElementCollection collection, XmlReader reader, ConfigPolicyHandler policyHandler, String policyName, UpgradingInfo upgradingInfo) +1326
       Telerik.Sitefinity.Configuration.Data.XmlConfigProvider.LoadElement(ConfigElement element, XmlReader reader, ConfigPolicyHandler policyHandler, String policyName, UpgradingInfo upgradingInfo, Boolean isNew, Boolean validateTagName) +398
       Telerik.Sitefinity.Configuration.Data.XmlConfigProvider.LoadPropertyElement(ConfigElement element, XmlReader reader, ConfigPolicyHandler policyHandler, String policyName, UpgradingInfo upgradingInfo) +478
       Telerik.Sitefinity.Configuration.Data.XmlConfigProvider.LoadElement(ConfigElement element, XmlReader reader, ConfigPolicyHandler policyHandler, String policyName, UpgradingInfo upgradingInfo, Boolean isNew, Boolean validateTagName) +435
       Telerik.Sitefinity.Configuration.Data.XmlConfigProvider.LoadCollectionElement(ConfigElementCollection collection, XmlReader reader, ConfigPolicyHandler policyHandler, String policyName, UpgradingInfo upgradingInfo) +1469
       Telerik.Sitefinity.Configuration.Data.XmlConfigProvider.LoadElement(ConfigElement element, XmlReader reader, ConfigPolicyHandler policyHandler, String policyName, UpgradingInfo upgradingInfo, Boolean isNew, Boolean validateTagName) +398
       Telerik.Sitefinity.Configuration.Data.XmlConfigProvider.LoadPropertyElement(ConfigElement element, XmlReader reader, ConfigPolicyHandler policyHandler, String policyName, UpgradingInfo upgradingInfo) +478
       Telerik.Sitefinity.Configuration.Data.XmlConfigProvider.LoadElement(ConfigElement element, XmlReader reader, ConfigPolicyHandler policyHandler, String policyName, UpgradingInfo upgradingInfo, Boolean isNew, Boolean validateTagName) +435
       Telerik.Sitefinity.Configuration.Data.XmlConfigProvider.LoadSectionFromReader(ConfigSection section, XmlReader reader, ConfigPolicyHandler policyHandler, String policyName, Boolean checkForUpgrade, UpgradingInfo& upgradingInfo) +422
       Telerik.Sitefinity.Configuration.Data.XmlConfigProvider.LoadSectionFromFile(ConfigSection section, ConfigPolicyHandler policyHandler, String policyName, Boolean withUpgrade) +136
       Telerik.Sitefinity.Configuration.Data.XmlConfigProvider.LoadSection(ConfigSection section, ConfigPolicyHandler policyHandler, String policyName) +126
       Telerik.Sitefinity.Configuration.ConfigSection.Initialize(ConfigProvider provider, ConfigPolicyHandler policyHandler, String policyName, Boolean singlePolicy) +260
       Telerik.Sitefinity.Configuration.ConfigSection.Initialize(ConfigProvider provider) +45
       Telerik.Sitefinity.Configuration.Config.GetConfigSection(String name) +362
       Telerik.Sitefinity.Configuration.Config.GetByPath(String path) +148
       Telerik.Sitefinity.Configuration.ConfigElementLink`1.get_Element() +148
       Telerik.Sitefinity.Configuration.ConfigElementDictionary`2.TryGetValueInternal(TKey key, TElement& element) +88
       Telerik.Sitefinity.Configuration.ConfigElementDictionary`2.get_Item(TKey key) +53
       Telerik.Sitefinity.Web.UI.ContentUI.ContentViewControlDefinition.GetConfigurationDefinition() +84
       Telerik.Sitefinity.Web.UI.DefinitionBase.get_ConfigDefinition() +48
       Telerik.Sitefinity.Web.UI.DefinitionBase.ResolveProperty(String propertyName, T instanceValue, T defaultValue) +376
       Telerik.Sitefinity.Web.UI.DefinitionBase.ResolveProperty(String propertyName, T instanceValue) +109
       Telerik.Sitefinity.Web.UI.ContentUI.ContentViewControlDefinition.get_ManagerType() +61
       Telerik.Sitefinity.Web.UI.ContentUI.ContentView.ResolveContentManager() +52
       Telerik.Sitefinity.Web.UI.ContentUI.ContentView.ResolveDetailItem() +128
       Telerik.Sitefinity.Web.UI.ContentUI.ContentView.CreateChildControls() +83
       System.Web.UI.Control.EnsureChildControls() +102
       System.Web.UI.Control.PreRenderRecursiveInternal() +42
       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
     
    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272
  2. Stanislav Velikov
    Stanislav Velikov avatar
    1113 posts
    Registered:
    18 Sep 2017
    16 Jul 2012
    Link to this post
    Hi,

    The error message indicates ContentViewDefinitionElement can`t instantiated because this class ContentViewDefinitionElement is abstract class. When using it  must call for non abstract class in order to work. This is a sample of how ContentViewDefinitionElement is used in Sitefinity source code.

    private static ContentViewDefinitionElement DefineProductAttributeBackendInsertView(ContentViewControlElement backendContentView)
           {
               var productAttributeInsertView = new DetailFormViewElement(backendContentView.ViewsConfig)
               {
                   Title = "CreateAProductAttribute",
                   ViewName = ProductAttributeDefinitions.ProductAttributesBackendInsertViewName,
                   ViewType = typeof(DetailFormView),
                   ShowSections = true,
                   DisplayMode = FieldDisplayMode.Write,
                   ShowTopToolbar = true,
                   ResourceClassId = typeof(CatalogResources).Name,
                   WebServiceBaseUrl = CatalogModule.productAttributesServiceUrl,
                   IsToRenderTranslationView = true,
                   UseWorkflow = false
               };
     
               ProductAttributeDefinitions.CreateBackendSections(productAttributeInsertView, FieldDisplayMode.Write);
               DefinitionsHelper.CreateBackendFormToolbar(productAttributeInsertView, typeof(CatalogResources).Name, true, "ThisProductAttribute", false, false, "BackToProductAttributes", false);
               return productAttributeInsertView;
           }
    ContentViewDefinitionElement is used to construct backend intefaces in Sitefinity. It is added to each content module Module_NameDefinition.cs class where the backend interface for the module is created.

    In the jobs module ContentViewDefinitionElement is not used to create the backend of the module.
    In case you have followed the documentation for create the jobs module you can also refer to the jobs module sample in Sitefinity SDK which is available to download from your client account. The jobs module sample in the SDK is fully implemented and working. I suggest copying the JobsDefinitions.cs implementation to your module or comparing the implementation in the two files.

    Alternatively you can show me the definitions file you have for your module here so I can better advise you where is the error coming from.


    Regards,
    Stanislav Velikov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. AJ
    AJ avatar
    11 posts
    Registered:
    17 Sep 2012
    16 Jul 2012
    Link to this post
    Ok, I did a comparison and the main difference I found was that I was missing the "public" declaration for the class. I since recompiled and re registered the module with a fresh sitefinity project and it didn't install. I have since found out about the error.log file in App_Data\Sitefinity\Logs and noticed the following error:

    Type : System.ArgumentException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
    Message : An item with the same key has already been added.
    Source : mscorlib
    Help link :
    ParamName :
    Data : System.Collections.ListDictionaryInternal
    TargetSite : Void ThrowArgumentException(System.ExceptionResource)
    Stack Trace :    at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
       at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
       at Telerik.Sitefinity.Configuration.ConfigElementDictionary`2.Add(TKey key, TElement element)
       at Telerik.Sitefinity.Configuration.ConfigElementDictionary`2.Add(TElement element)
       at Jobs.Resources.JobsDefinitions.DefineJobsBackendContentView(ConfigElement parent) in C:\working\Sitefinity 5.0\Projects\Jobs\Resources\JobsDefinitions.cs:line 84
       at Jobs.Configuration.JobsConfig.InitializeDefaultViews(ConfigElementDictionary`2 contentViewControls) in C:\working\Sitefinity 5.0\Projects\Jobs\Configuration\JobsConfig.cs:line 26
       at Telerik.Sitefinity.Modules.GenericContent.Configuration.ContentModuleConfigBase.OnPropertiesInitialized()
       at Telerik.Sitefinity.Configuration.ConfigSection.InitializeProperties()
       at Telerik.Sitefinity.Configuration.ConfigElement.EnsurePropertiesInitialized()
       at Telerik.Sitefinity.Configuration.ConfigElement.get_Properties()
       at Telerik.Sitefinity.Configuration.ConfigElement.get_Item(String propertyName)
       at Telerik.Sitefinity.Modules.GenericContent.Configuration.ContentModuleConfigBase.get_ContentViewControls()
       at Telerik.Sitefinity.Services.ModuleBase.InstallContentViews(SiteInitializer initializer, Version upgradeFrom)
       at Telerik.Sitefinity.Services.ModuleBase.Install(SiteInitializer initializer, Version upgradeFrom)
       at Telerik.Sitefinity.Services.SystemManager.InitializeModule(ModuleSettings settings, InstallContext installContext, Boolean start)

    I am fairly certain I haven't used this module in this sitefinity project before, so what could be happening? And even if I have, how can I get around this error?

    Cheers

    AJ
  4. Stanislav Velikov
    Stanislav Velikov avatar
    1113 posts
    Registered:
    18 Sep 2017
    17 Jul 2012
    Link to this post
    Hi,

    A module with the same name have been registered in the project before. This is the cause of the error "An item with the same key has already been added."

    There is no uninstall procedure for a module that will completely remove it from Sitefinity since the module uses mapping to the database and the tables it have created in the database remain.
    The module writes it in the configuration files of Sitefinity located in App_Data/Sitefinity/Configuration. Remove the module entry from the configuration files
    SystemConfig.config
    The registration for the module must appear in this configuration file if it have been registered trough Administration->Settings->Advanced->System
    <add title="Jobs" type="Jobs.JobsModule" startupType="OnApplicationStart" name="Jobs" />

    SecurityConfig.config
    There must be an entry for the module.
    <customSet setName="Jobs">
                <securedObjectCustomPermissionSets>
                    <securedObjectType typeName="Jobs.Model.JobApplication">
    ...
    Restart the application and try to register the module again.
    I suggest when registering the module to just paste this registration in SystemConfig.config
    <add title="Jobs" type="Jobs.JobsModule" startupType="OnApplicationStart" name="Jobs" />
    This registration registers the jobs module from Sitefinity SDK as it follows the class name of the module and its namespace to register the type of the module to type="Jobs.JobsModule" (namespace.class of the JobsModule.cs file where the Install method is located).

    If you have updated the JobsDefinitions file making the class public the easiest way to use the updated code is to set the AssemblyVersion of the module to be auto incremented after each build by using this in AssemblyInfo.cs of the Jobs module project
    [assembly: AssemblyVersion("1.0.*")]
    [assembly: AssemblyFileVersion("1.0.0.0")]
    After the build Sitefinity will get notified for the change of the module version and will update the changes in the registered module in Sitefinity backend.
    When a module is installed in Sitefinity its assembly version is automatically added in SystemConfig.config and the version updates automatically.
    <add title="Jobs" type="Jobs.JobsModule" startupType="OnApplicationStart" version="1.2.3.56" name="Jobs" />
    With this you will be able to observe the result of the fix you have done in the project you have been working with when you get the error for "Cannot create an instance of Telerik.Sitefinity.Web.UI.ContentUI.Config.ContentViewDefinitionElement because it is an abstract class.".


    All the best,
    Stanislav Velikov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. AJ
    AJ avatar
    11 posts
    Registered:
    17 Sep 2012
    17 Jul 2012
    Link to this post
    Hi Stanislav,

    Thanks for your help in this, I've now managed to get the module registered.

    I did encounter an error but found it was because I was trying to add the same column to the admin view twice (that'll teach me for copy and pasting!)

    Cheers!
5 posts, 0 answered