When trying to view or edit a workflow, the following error can pop up:

An unexpected error has occurred while opening the workflow. See the event log on the AOS and contact your system administrator to resolve the issue.

This is a general error and it could mean a lot of things. Make sure you check the obvious things first:

  • Make sure that the build number of the client maches the build number of the server
  • Make sure x++ compilation has been done on the AOT
  • Make sure CIL is compiled without errors
  • Do a data dictionary synchronization
  • Refresh the WCF configuration using the Dynamics AX 2012 Configuration utility
  • Remove the AUC files and KTI files from the %localappdata% directory
  • Remove usage data

Well… you know… do the usual.

In my case, none of this helped. Because this was a CLR exception, I modified the try/catch in the method that was throwing the error to show the inner exception. The method Forms\WorkflowEditorHost.run was modified so it looked like this:

public void run()
{
    System.Exception interopException;
   
    try
    {
        modelEditorControl.Load(workflowConfiguration, userSettings); // <- error thrown here
        [some more std code]
    }
    catch (Exception::CLRError)
    {
        interopException = CLRInterop::getLastException();
        while (!CLRInterop::isNull(interopException.get_InnerException()))
        {
            interopException = interopException.get_InnerException();
        }

        error(strFmt("%1", CLRInterop::getAnyTypeForObject(interopException.get_Message())));
        throw error("@SYS327400");
    }

    super();
}

After trying to open the workflow again, this was the inner exception:

Kan een object van het type System.Windows.Input.CommandBinding niet converteren naar het type System.Activities.Presentation.View.DesignerView.

Translated:

Cannot convert an object of type System.Windows.Input.CommandBinding to the type System.Activities.Presentation.View.DesignerView.

The fact that the error was in Dutch gave me a clue. Turn out a language pack for .NET framework 4 was installed on the machine. However, recently the .NET framework 4.5.2 was also installed on that machine. After installing the Language Pack for Microsoft .NET Framework 4.5 (link) and rebooting the machine, the error was solved.