Friday, May 30, 2014

Code Activities Exceptions at Workflow Publishing

I encountered a problem when your old workflows, that already have been working, was caused exceptions on publishing. For example, this forum discussion. You may spent many hours to make them work again. Let's dive!
  

1. Cannot find activity in your clr-namespace:

 Microsoft.Workflow.Client.ActivityValidationException: 
 Workflow XAML failed validation due to the following errors: 
 Cannot create unknown type   
 '{clr-namespace:My.Custom.Activities.Namespace;
 assembly=My.Custom.Activities.Assembly}MyActivity'.  

Possible server responses in this case:
  • The remote server returned an error: (400) Bad Request.
 To solve that you may do next:
  1. re-install DLL in GAC (with 'force' attribute), link,
  2. re-register workflow service application (with 'force' attribute), link,
  3. disable default custom code protection,
  4. re-add your custom code activities to the workflow pane from toolbox, rebuild project,
  5. and then restart workflow manager service.
After that you may get another exception.

2. Unknown type '{wf://workflow.windows.net...'

 Microsoft.Workflow.Client.ActivityValidationException: 
 Workflow XAML failed validation due to the following errors: 
 Cannot create unknown type 
'{wf://workflow.windows.net/default/ ... }MyActivity'.  

Possible server responces:
  • The remote server returned an error: (400) Bad Request
  • The remote server returned an error: (404) Not found
In forum above you may find a possible solution - add line to AssemblyInfo.cs of your project:
  • [assembly: System.Windows.Markup.XmlnsDefinition("wf://workflow.windows.net/$Current/$Activities", "My.Custom.Activities.Namespace")]
But that may not help. You even may get project compiling fail.
If you look at your .xaml file of workflow in XML editor, you'll see a line in a head for standard activities:
  • xmlns:p1="wf://workflow.windows.net/$Activities" 
And for your custom activities:
  •  xmlns:p2="wf://workflow.windows.net/$Current/$Activities"
and your custom activities will have p2 prefix (in .xaml below).
For solution just redefine this line:
  • xmlns:p2="clr-namespace:My.Custom.Activities.Namespace;assembly=My.Custom.Activities.Assembly"
(carefully fill namespace and assembly). And if there is any exception about clr-namespace - see solution on issue 1 in this article.

No comments:

Post a Comment