I get the following error: “System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.” when I add a .Net UserControl to my web form

Issue

I get the following error: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary. when I add a .Net UserControl to my web form.

Solution

You will get this error if the registration of your UserControl to the WorkflowPage class is missing. This is only applicable in Advanced Mode, and not needed when you are in Simple Mode.

See the Can I dynamically add a UserControl to my WorkflowGen web form? article for more information on form data definition and restiration of UserControls in Advanced Mode.