How to correctly save a WF4 ActivityBuilder
===

I am currently saving my .NET FX 4.0.1 StateMachine activity like this:

    var sb = new StringBuilder();
    var xamlWriter = ActivityXamlServices.CreateBuilderWriter(
                         new XamlXmlWriter(new StringWriter(sb),
                         new XamlSchemaContext()));
    XamlServices.Save(xamlWriter, activityBuilder);

    return sb.ToString();

This works fine and the generated XAML looks good. Unfortunately, it is invalid. I can read it back in using `ActivityXamlServices.Load` but when I execute it, it says that it doesn't know the properties defined in the workflow. Opening it in the Visual Studio designer yields the same errors:

> Compiler error(s) encountered processing expression "ActiveCall". "ActiveCall" is not declared. It may be inaccessible due to its protection level.

Through comparing the original XAML with the XAML produced by my code, I found out, how to fix this problem. I have to have this tag before the `StateMachine` tag:

    <mva:VisualBasic.Settings>
        Assembly references and imported namespaces for internal implementation
    </mva:VisualBasic.Settings>

The text inside the tag must be exactly like this, otherwise there will be an error when opening the WF in VS:

> Failed to create a 'Settings' from the text 'FooBar'

**Question:**  
What do I have to change in my code to have this tag in the generated XAML?