Search code examples
workflow-foundation-4

Workflow Foundation 4 Imports panel not refreshed


I would like to import a new reference into my Workflow Designer, however I encounter a weird problem.

Here's my code to import a reference.

var root = GetRootElement();
VisualBasicSettings vbs = VisualBasic.GetSettings(root);
vbs.ImportReferences.Add(new VisualBasicImportReference { Assembly = Assembly.Load("Castle.Core").FullName, Import = "Castle.Core.Configuration.Xml" });

private object GetRootElement()
{
     var modelservice = workflowDesigner.Context.Services.GetService<ModelService>();
     if (modelservice == null)
         return null;
     var rootmodel = modelservice.Root.GetCurrentValue();
     return rootmodel;
}

It works when I load my designer for the first time, the assembly is well added into the hashset ImportReferences then I also see the namespace in the "Imports" panel. But when I call the above method when user picks a dll through a picker dialog, I call the code above, the assembly is also well added to ImportReferences, but the "Imports" panel is not refreshed...

Any ideas ?

Thanks for your help.


Solution

  • Actually, the namespace is well imported, it was hided in the dropdownlist above.

    Here's the most simple code to import a namespace. http://blogs.msdn.com/b/tilovell/archive/2011/11/02/wf4-adding-vb-namespace-imports-to-your-workflow-programmatically.aspx