How do I save the XAML for a WF4 workflow in a rehosted designer, without writing it to a file? I want to store the serialised workflow in a database as an XML string.
Given a WorkflowDesigner instance called w, this saves to a file fine:
WorkflowDesigner.Flush();
w.Save("filename.xaml");
I was hoping this would serialise to a string - but it fails:
WorkflowDesigner.Flush();
var modelService = WorkflowDesigner.Context.Services.GetService<ModelService>();
var workflow = modelService.Root;
var xml = XamlServices.Save(workflow);
... while saving a single Sequence activity, it says "Type 'System.Activities.Presentation.Model.ModelItemImpl' not visible. If the type is local, please set the LocalAssembly field in XamlReaderSettings.