Ticket T595785
Visible to All Users

An item with the same key has already been added - XAF Windows Only

created 7 years ago

Hi

I have been working on a project using the XAF framework, focusing on the Web aspect of the project, although the windows and mobile projects are already part of the solution, i now need to get the windows project working however when i load the project i am presented with the "An item with the same key has already been added", i am unsure as to why i have this problem, if i had accidentally used  the same key (although i can not see a duplicate) then would the web project not also present the same problem?

I have not made any changes to the Windows application model, however if i hide all of the navigation items the error does not appear, but of course i can not navigate/use my application.

FYI - after i click OK on the error message if i attempt to click on any of the navigation items such as My Details then i am again presented with the error message and the required view is not displayed.

Also the Mobile application works fine.

Can you point me in the necessary direction so that i can resolve this issue

Thanks

Andrew

Error Message Box:

C#
An item with the same key has already been added. at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value) at DevExpress.ExpressApp.Win.Templates.Bars.ActionControls.BarLinkActionControlContainer.AddActionControl(IActionControl actionControl) at DevExpress.ExpressApp.Win.Templates.Bars.ActionControls.BarLinkActionControlContainer.AddSimpleActionControl(String actionId) at DevExpress.ExpressApp.Templates.ActionControls.ActionControlContainerManager.AddActionControl(ActionBase action, IActionControlContainer container) at DevExpress.ExpressApp.Templates.ActionControls.ActionControlContainerManager.AddActionControlsToContainer(IActionControlContainer container, String actionCategory) at DevExpress.ExpressApp.SystemModule.ActionControlsSiteController.AddActionControlsToContainers(IActionControlsSite site, IEnumerable`1 actions, IModelActionToContainerMapping actionToContainerMapping) at DevExpress.ExpressApp.SystemModule.ActionControlsSiteController.Frame_TemplateChanged(Object sender, EventArgs e) at System.EventHandler.Invoke(Object sender, EventArgs e) at DevExpress.ExpressApp.Frame.OnTemplateChanged() at DevExpress.ExpressApp.Win.WinWindow.OnTemplateChanged() at DevExpress.ExpressApp.Frame.SetTemplate(IFrameTemplate val) at DevExpress.ExpressApp.Frame.CreateTemplate() at DevExpress.ExpressApp.Win.WinWindow..ctor(XafApplication application, TemplateContext context, ICollection`1 controllers, Boolean isMain, Boolean activateControllersImmediately) at DevExpress.ExpressApp.Win.WinApplication.CreateWindowCore(TemplateContext context, ICollection`1 controllers, Boolean isMain, Boolean activateControllersImmediately) at DevExpress.ExpressApp.XafApplication.CreateWindow(TemplateContext context, ICollection`1 controllers, Boolean createAllControllers, Boolean isMain, View view) at DevExpress.ExpressApp.Win.WinShowViewStrategyBase.CreateWindow(ShowViewParameters parameters, ShowViewSource showViewSource, Boolean isMain) at DevExpress.ExpressApp.Win.WinShowViewStrategyBase.CreateInspectorWindow(ShowViewParameters parameters, ShowViewSource showViewSource) at DevExpress.ExpressApp.Win.MdiShowViewStrategy.CreateInspectorWindow(ShowViewParameters parameters, ShowViewSource showViewSource) at DevExpress.ExpressApp.Win.MdiShowViewStrategy.ShowViewInInspector(ShowViewParameters parameters, ShowViewSource showViewSource) at DevExpress.ExpressApp.Win.WinShowViewStrategyBase.ShowViewInNewWindow(ShowViewParameters parameters, ShowViewSource showViewSource) at DevExpress.ExpressApp.Win.MdiShowViewStrategy.ShowViewInCurrentWindow(ShowViewParameters parameters, ShowViewSource showViewSource) at DevExpress.ExpressApp.ShowViewStrategyBase.ShowViewCore(ShowViewParameters parameters, ShowViewSource showViewSource) at DevExpress.ExpressApp.Win.MdiShowViewStrategy.ShowViewCore(ShowViewParameters parameters, ShowViewSource showViewSource) at DevExpress.ExpressApp.ShowViewStrategyBase.ShowView(ShowViewParameters parameters, ShowViewSource showViewSource) at DevExpress.ExpressApp.Frame.ProcessActionCreatedView(ActionBaseEventArgs e) at DevExpress.ExpressApp.Win.WinWindow.ProcessActionCreatedView(ActionBaseEventArgs e) at DevExpress.ExpressApp.Frame.ShowViewAction_ProcessCreatedView(Object sender, ActionBaseEventArgs e) at DevExpress.ExpressApp.Actions.ActionBase.OnProcessCreatedView(ActionBaseEventArgs e) at DevExpress.ExpressApp.Actions.ActionBase.ExecuteCore(Delegate handler, ActionBaseEventArgs eventArgs)

Error message from eXpressAppFramework.log

C#
15.01.18 09:52:15.594 CurrentObject: Admin 15.01.18 09:52:15.609 WinApplication.CreateWindowCore.activateControllersImmediately: True 15.01.18 09:52:15.611 Window.activateControllersImmediately: True 15.01.18 09:52:15.612 WinWindow.activateControllersImmediately: True 15.01.18 09:52:15.630 Frame.set_Template: old value - null, new value - DevExpress.ExpressApp.Win.Templates.Ribbon.DetailRibbonFormV2 ProjectEve_XAF.Win.exe Error: 0 : 15.01.18 09:52:15.641 ================================================================================ The error occurred: Type: ArgumentException Message: An item with the same key has already been added. Data: 0 entries Stack trace: at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value) at DevExpress.ExpressApp.Win.Templates.Bars.ActionControls.BarLinkActionControlContainer.AddActionControl(IActionControl actionControl) at DevExpress.ExpressApp.Win.Templates.Bars.ActionControls.BarLinkActionControlContainer.AddSimpleActionControl(String actionId) at DevExpress.ExpressApp.Templates.ActionControls.ActionControlContainerManager.AddActionControl(ActionBase action, IActionControlContainer container) at DevExpress.ExpressApp.Templates.ActionControls.ActionControlContainerManager.AddActionControlsToContainer(IActionControlContainer container, String actionCategory) at DevExpress.ExpressApp.SystemModule.ActionControlsSiteController.AddActionControlsToContainers(IActionControlsSite site, IEnumerable`1 actions, IModelActionToContainerMapping actionToContainerMapping) at DevExpress.ExpressApp.SystemModule.ActionControlsSiteController.Frame_TemplateChanged(Object sender, EventArgs e) at System.EventHandler.Invoke(Object sender, EventArgs e) at DevExpress.ExpressApp.Frame.OnTemplateChanged() at DevExpress.ExpressApp.Win.WinWindow.OnTemplateChanged() at DevExpress.ExpressApp.Frame.SetTemplate(IFrameTemplate val) at DevExpress.ExpressApp.Frame.CreateTemplate() at DevExpress.ExpressApp.Win.WinWindow..ctor(XafApplication application, TemplateContext context, ICollection`1 controllers, Boolean isMain, Boolean activateControllersImmediately) at DevExpress.ExpressApp.Win.WinApplication.CreateWindowCore(TemplateContext context, ICollection`1 controllers, Boolean isMain, Boolean activateControllersImmediately) at DevExpress.ExpressApp.XafApplication.CreateWindow(TemplateContext context, ICollection`1 controllers, Boolean createAllControllers, Boolean isMain, View view) at DevExpress.ExpressApp.Win.WinShowViewStrategyBase.CreateWindow(ShowViewParameters parameters, ShowViewSource showViewSource, Boolean isMain) at DevExpress.ExpressApp.Win.WinShowViewStrategyBase.CreateInspectorWindow(ShowViewParameters parameters, ShowViewSource showViewSource) at DevExpress.ExpressApp.Win.MdiShowViewStrategy.CreateInspectorWindow(ShowViewParameters parameters, ShowViewSource showViewSource) at DevExpress.ExpressApp.Win.MdiShowViewStrategy.ShowViewInInspector(ShowViewParameters parameters, ShowViewSource showViewSource) at DevExpress.ExpressApp.Win.WinShowViewStrategyBase.ShowViewInNewWindow(ShowViewParameters parameters, ShowViewSource showViewSource) at DevExpress.ExpressApp.Win.MdiShowViewStrategy.ShowViewInCurrentWindow(ShowViewParameters parameters, ShowViewSource showViewSource) at DevExpress.ExpressApp.ShowViewStrategyBase.ShowViewCore(ShowViewParameters parameters, ShowViewSource showViewSource) at DevExpress.ExpressApp.Win.MdiShowViewStrategy.ShowViewCore(ShowViewParameters parameters, ShowViewSource showViewSource) at DevExpress.ExpressApp.ShowViewStrategyBase.ShowView(ShowViewParameters parameters, ShowViewSource showViewSource) at DevExpress.ExpressApp.Frame.ProcessActionCreatedView(ActionBaseEventArgs e) at DevExpress.ExpressApp.Win.WinWindow.ProcessActionCreatedView(ActionBaseEventArgs e) at DevExpress.ExpressApp.Frame.ShowViewAction_ProcessCreatedView(Object sender, ActionBaseEventArgs e) at DevExpress.ExpressApp.Actions.ActionBase.OnProcessCreatedView(ActionBaseEventArgs e) at DevExpress.ExpressApp.Actions.ActionBase.ExecuteCore(Delegate handler, ActionBaseEventArgs eventArgs) InnerException is null

Answers approved by DevExpress Support

created 7 years ago (modified 7 years ago)

Hello Andrew,

This issue occurs, because actions with the same ID are added to one of the application's Action Containers. Since XAF does not allow registering multiple actions with the same ID, it is likely that the same action has been added twice, or an action has been registered after the Application Model is validated. We cannot determine the precise cause of this error by the Call Stack. Please check if one of the following events is handled in your application:
ActionControlsSiteController.CustomizeContainerActions
ActionControlsSiteController.CustomAddActionControlToContainer
ActionControlContainerManager.CustomizeContainerActions

If this does not help, you can determine which Action and Action Container cause this issue by debugging our sources using PDB files - How can I debug DevExpress .NET source code using PDB files. Alternatively, provide a sample project where the issue can be reproduced.

    Comments (2)
    AC AC
    Andrew Cunningham 4 7 years ago

      Thank you this help me solve the issue.

      Anatol (DevExpress) 7 years ago

        Great! Please do not hesitate to contact us if you need further assistance.

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.