An item key had already been added Key: Project location\"codedworkflow.cs"

I am getting a compilation failed or was cancelled error when trying to run my workflow. It says that an item with the same key has already been added. Key: Project location"codedworkflow.cs" not sure how to fix this. The program was running just fine and than i restarted my computer and now i get the error. Any help would be much appreciated.

Hi @Ahead_Engineering

Close the UipathStudio and reopen it again.

  1. Check the project location to make sure it is valid.
  2. If the project location is already in use by another project, close the other project and try running your workflow again.
  3. If the project location is corrupt, you can try deleting the project and recreating it.

Hope it helps!!

I appreciate you help. I did all of the above and even started a new project and just copied and pasted all the code into the new project and still got the same error. Will i need to completely redo the entire project?


Check the code for syntax errors,logical errors.
Run in the debug mode step to step through the code and see where the error is occurring.

Hope it helps!!

Hi @Ahead_Engineering,

Thanks for letting us know of this potential issue.

Do you by any chance have CodedWorkflow.cs open in a tab and have the restore tabs on project open functionality enabled?

Otherwise, could you attach a small project where this reproduces?

Also, please let us know what Studio version you are using. In case you are still using the insider preview version, I would recommend updating to the 23.6.1 Community Preview.


My experience of coded workflows is they dont play nice with ‘Process’ project types but better / well with library project types.

Either way they are in private preview so I suggest you report this via the insider portal.

Hi @Ahead_Engineering

it’s likely related to your workflow or project structure. Here are some steps you can take to troubleshoot and resolve the issue:

  1. Check for duplicate files: Make sure there are no duplicate files with the same name, such as “codedworkflow.cs,” in your UiPath project. Duplicate files can cause conflicts and result in compilation errors.
  2. Verify project dependencies: Ensure that your project dependencies, such as custom activities or libraries, are properly installed and referenced. In UiPath Studio, go to Manage Packages and check for any duplicate or conflicting packages. Remove any unnecessary or conflicting packages and reinstall them if needed.
  3. Clear project cache: UiPath Studio maintains a cache of project files and dependencies. Sometimes, this cache can become corrupted and cause compilation errors. To clear the cache, close UiPath Studio, navigate to the %userprofile%\.nuget\packages folder, and delete the contents. Then reopen UiPath Studio and try running the workflow again.
  4. Restart UiPath Studio: A simple restart of UiPath Studio can sometimes resolve temporary issues or conflicts that may have occurred.
  5. Review workflow activities: Analyze the workflow file (“codedworkflow.xaml”) for any conflicting activities or variables. Ensure that you are not using the same key or variable name multiple times within the workflow, as this can cause conflicts during compilation.
  6. Reinstall UiPath Studio: If the issue persists, you can try reinstalling UiPath Studio to ensure that all components are in a consistent state. Uninstall UiPath Studio from your computer, download the latest version from the UiPath website, and perform a fresh installation.
  7. Contact UiPath support: If none of the above steps resolve the issue, it’s advisable to reach out to UiPath support for further assistance. They can provide specific guidance based on the error message and help troubleshoot the problem.

Remember to provide detailed information about the error message, your UiPath Studio version, and any specific actions or changes you made before encountering the error when contacting UiPath support.

I do not have CodedWorkFlow.cs open tab open and there is only 1 file in the local folder with CodedWorkFlow.cs in the project folder. I have uninstalled and reinstalled UiPath and i still get the same error. I also ran the program on debug mode and it errors out before it gets to the program steps.

Originally the program was working fine, until i restarted my computer.

I dont know if this can be the cause, but in my imported namespaces, “GlobalConstantsNamespace” and “GlobalVariablenamespace” "Can not be resolved. not sure if that could be a possible issue. Also, i updated the studio to 2023.6.1 and this is when the error started.

@Ahead_Engineering Can you please attach a sample project where this reproduces so that we can take a look and try to resolve the issue in the next Community preview?