Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

workflow instance throwing the following error: "An item with the same key has already been added."

Posted on by Microsoft Employee

Hello,

I've got a workflow instance stuck in a waiting state with the following error: "An item with the same key has already been added."

Here's the stack trace:

"Unhandled Exception: System.ArgumentException: 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 Microsoft.Crm.Workflow.ActivityHostBase.OnWorkflowLoaded(WorkflowApplication activityInstance, ICommonWorkflowContext context)
at Microsoft.Crm.Workflow.ActivityHost.StartWorkflowExecution(Activity workflow, ICommonWorkflowContext context)
at Microsoft.Crm.Workflow.ActivityHostBase.StartWorkflow(ICommonWorkflowContext context, Activity preLoadedActivity)"

Has anyone encountered this issue before?  If so, how was it solved?

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: workflow instance throwing the following error: "An item with the same key has already been added."

    Thanks for the response Nadeeja,

    I'm using CRM 2016 on premise.

    I do have a custom code activity in the workflow, but next to its step I see the green check mark indicating success.

    The custom code activity only sets some entity reference output parameters. I am not inserting existing attributes into an entity anywhere. It is puzzling to me where the dictionary is coming from in the stack trace.

    I also have numerous tracing statements in the code activity. I don't see them showing up under the Plug-in trace logs.  (Yes, I have turned on tracing in the settings)

  • Suggested answer
    Nadeeja Bomiriya Profile Picture
    Nadeeja Bomiriya 6,804 on at
    RE: workflow instance throwing the following error: "An item with the same key has already been added."

    Hi Crispin,

    Which version of CRM is it?

    Do you have any custom workflow activities in the workflow?

    Possible reason is that you are trying to add an attribute to an entity that's already which already exists.

    Check out this thread.

    https://community.dynamics.com/crm/f/117/t/163705

    Cheers,

    Nadeeja

    If the answer solves your problem, please mark as Verified. Thanks.

    My Blog: http://dyn365apps.com/ - Follow me on Twitter: https://twitter.com/dyn365apps

    LinkedIn: https://www.linkedin.com/in/nadeeja

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans