Tuesday, September 11, 2012 12:16 PM
I get the same exception when trying to load a wf definition in a rehosted designer. In general I have VisualBasic activity, which could contain expression which is not valid sometimes. I have to provide an option for the user to open the wf definition, despite this, in order to fix the expression. THe problem is that The wf throws InvalidWorkflowException when trying to write CacheMetadata and the definition could not be opened in the rehosted designer.
We cannot use .net 4.5
Do you have in mind a workaround for this issue?
I also get this exception in the following situation: If I add a ValidationError, with the last option set to type Error, not Warning and save/close the wf definition, I can't load it in the rehosted designer anymore.
This is the code which throws the exception:
using (var rdrStr = new StringReader(View.WorkflowDesigner.Text))
if (!View.WorkflowDesigner.Text.StartsWith("<ActivityBuilder" ))
root = ActivityXamlServices.Load(rdrStr) as DynamicActivity;
Thursday, September 13, 2012 6:45 PMModerator
I see your code which throws. I believe it is normal for this to throw, because DynamicActivity class is intended to be used for executing a workflow, and executing the workflow obviously requires that it is a valid workflow.
Now it sounds like this is a design time situation so I didn't understand exactly why you're using this code, which loads DynamicActivity from your workflow designer text. Would you mind giving a little bit more background on why you're doing this?
Friday, September 14, 2012 10:11 AM
We are rehosting workflow designer. The user can add an arithmetic expression in one of our activities. This arithmetic expression can use for example a globalvariable which is defined in the workflow metadata. All global variables are editable/deletable and if the user deletes a variable which takes part in the expression it becomes invalid. The exception is CompileTime error: The 'globalvariablename' is undefined. This is ok, but i have requrements to be able to save->close->reopen the workflow in the designer in order to allow the user to change the definition after some time. We do not allow this workflow to be instanciated until all errors are gone, but I need it in design time. Actually when I try to design a wf with this compile time error CacheMetadata do not agree with me and the process is terminated.
I was wondering if there is a workaround that will allow me to open in the rehosted designer this wrong workflow
Friday, September 14, 2012 6:01 PMModerator
I'm still confused so I'll rephrase my confusion in a different way:
-why not just NOT call CacheMetadata?
-or if you have to call it, why not just catch the exception?