I've created a custom module to seed a new application with non-Kentico legacy data. The application is throwing the following error on build while debugging. I am compiling to a package which will be removed after soon after the production release. The error is thrown at the .AddKentico middleware.
Cannot dynamically create an instance of type 'Custom.Admin.SeedModule'. Reason: No parameterless constructor defined.
at System.RuntimeType.ActivatorCache..ctor(RuntimeType rt)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions)
at CMS.Core.ModuleDiscovery.<>c.<GetModules>b__1_0(RegisterModuleAttribute attribute)
at System.Linq.Enumerable.SelectArrayIterator`2.MoveNext()
at System.Collections.Generic.List`1.AddRange(IEnumerable`1 collection)
at CMS.Core.ModuleDiscovery.GetModules()
at CMS.Core.ModuleEntryManager.GetDiscoverableModules()
at CMS.Core.ModuleEntryManager.ModuleCollectionsInitialization()
at CMS.Core.ModuleEntryManager.PreInit()
at CMS.Core.AppCore.PreInit()
at CMS.DataEngine.CMSApplication.PreInit(Boolean initializeContainer)
at Kentico.Web.Mvc.IServiceCollectionExtensions.PreInitCmsApplication()
at Kentico.Web.Mvc.IServiceCollectionExtensions.AddKenticoCore(IServiceCollection services)
at Kentico.Web.Mvc.StartupExtensions.AddKentico(IServiceCollection services, Action`1 featuresBuilder)
at <CLASS>.Domain.SiteExtensions.ServiceCollections.AddKenticoServices(IServiceCollection services, WebApplicationBuilder builder) in C:\<PATH>\ServiceCollections.cs:line 49
at Program.<Main>$(String[] args) in C:\<PATH>\Program.cs:line 36
// ServiceCollection
services.AddKentico(features =>
{
features.UsePageBuilder(new PageBuilderOptions
{
//ContentTypeNames = new[]
//{
// ...
//}
});
features.UseActivityTracking();
features.UseWebPageRouting();
features.UseEmailStatisticsLogging();
features.UseEmailMarketing();
});
//Custom Class Module
[assembly: AssemblyDiscoverable]
[assembly: RegisterModule(typeof(SeedModule))]
namespace Custom.Admin;
public class SeedModule : Module
//Current Constructor
public SeedModule(string moduleName) : base(nameof(SeedModule)) {}
//OnInit
protected override void OnInit()
{
base.OnInit();
Service.Resolve<IEventLogService>().LogInformation("SEED_MODULE", "ORS", "Seed Module initialized");
}
Environment
- Xperience by Kentico version: [30.0.1]
- .NET version: [8]
- Execution environment: [Private cloud (AWS/Localhost)]
- Link to relevant Xperience by Kentico documentation