Developer forum

Forum » Dynamicweb 9.0 Upgrade issues » Upgrade to 9.4.7: An item with the same key has already been added.

Upgrade to 9.4.7: An item with the same key has already been added.

Anders Ebdrup
Anders Ebdrup
Reply

Hi Dynamicweb,

 

After upgrading to 9.4.7 from 9.4.5 we have an error and cannot access the site:

[ArgumentException: An item with the same key has already been added.]
   System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) +56
   System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) +14685443
   System.Linq.Enumerable.ToDictionary(IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer) +277
   Dynamicweb.Modules.ModuleManager.RegisterModules() +245
   Dynamicweb.Modules.ModuleManager.Initialize() +118
   Dynamicweb.Frontend.GlobalAsaxHandler.StartDynamicweb(Object sender, EventArgs e) +863
   Dynamicweb.Frontend.GlobalAsaxHandler.EnsureDynamicwebStarted(Object sender, EventArgs e) +140
   Dynamicweb.Frontend.GlobalAsaxHandler.Application_BeginRequest(Object sender, EventArgs e) +148
   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +136
   System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +195
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +88

Screen dump is available here: https://www.screencast.com/t/wlkjn1BfMT

Best regards, Anders

 


Replies

 
Anders Ebdrup
Anders Ebdrup
Reply

I found out that it is related to our module registration, which, in the new version, puts in information multiple times in the table Module

 
Morten Bengtson Dynamicweb Employee
Morten Bengtson
Reply

Hi Anders,

I couldn't find any changes between 9.4.5 and 9.4.7 related to how we handle module registrations.
Can you provide more details about how the modules are registered in your application?

Custom modules can be registered automatically by using module annotations...

using Dynamicweb.Core.UI.Icons;
using Dynamicweb.Modules;
using Dynamicweb.Modules.Annotations;

namespace Dynamicweb.Examples
{
    [ModuleName("ModuleSystemName", "Module name")] // Required.
    [ModuleDescription("Some description of thís module")] // Optional.
    [ModuleIcon(KnownIcon.Tasks)] // Optional. The name of a known icon in Dynamicweb which will be displayed in the management UI. See documentation for details.
    [ModuleEditPanel("/CustomModules/ModuleSystemName/ModuleSystemName_Edit.ascx")] // Optional. Path to the module edit panel of this module (.ascx or .aspx).
    [ModuleControlPanel("/CustomModules/ModuleSystemName/ModuleSystemName_ControlPanel.aspx")] // Optional. Path to the control panel of this module (.aspx).
    [ModuleScriptPanel("/CustomModules/ModuleSystemName/ModuleSystemName_Admin.aspx")] // Optional. Full path to the management panel of this module (.aspx).
    [ModuleAccess(true)] // Optional. Setting this to false will disable this module by default. Default value is true.
    public class ContentModuleWithAnnotationsSample : ContentModule
    {
        public override string GetContent()
        {
            return "Hello world";
        }
    }
}

Best regards,
Morten

 
Anders Ebdrup
Anders Ebdrup
Reply

Hi Morten,

 

Thank you for your very thorough response! Nice with all the action attributes! :-)

 

Our issue has been located to this line, which now only looks into internal features in Dynamicweb:

Dynamicweb.Security.UserManagement.License.IsModuleAvailable("ModuleSystemName")

 

We have used the line to check whether to register a module on start up. We have now changed this to:

new Dynamicweb.Modules.ModuleService().GetBySystemName("ModuleSystemName") == null

 

Best regards, Anders

 

You must be logged in to post in the forum