Summary
When publishing a workflow, you may receive the following error message:
Laserfiche.Workflow.LaserficheWorkflowServiceException: Failed to publish workflow. [0213-S9] ---> System.ArgumentException: An item with the same key has already been added.
Cause
This error can occur when the workflow definition contains activities with the same name. Be aware that workflow definitions are stored in XML format. In order to create a valid XML output, Workflow will automatically encode any applicable characters. This can potentially create a situation where you will encounter this error when publishing a workflow definition with two activities that are similarly named, but do not appear to have the exact name. However, during the publishing process, the encoded activity names end up being the same.
Workaround
Use the "FindUnsafeWFNames.exe" command line utility to look through a workflow definition's .wfx file and return a list of activities that when published, will end up with the same XML-safe name.
To download the FindUnsafeWFNames.exe command line utility
The utility accepts one parameter, the path to a .wfx file. Please see the following example:
FindUnsafeWFNames "C:\My WF Definitions\MyWorkflow.wfx"
Rename the listed activities before publishing the workflow.