How to add types from external assembly to toolbox control? (WPF)
- by Louis Rhys
I am trying to do something like this in my WPF application:
ToolboxControl ctrl = new ToolboxControl();
Assembly assembly = Assembly.LoadFile(file);
var category = new ToolboxCategory(assembly.GetName().Name);
foreach (Type t in assembly.GetTypes())
{
var wrapper = new ToolboxItemWrapper(t, t.Name);
category.Add(wrapper);
}
ctrl.Categories.Add(category);
i.e. adding ToolboxItemWrappers for each type found in an assembly. However the last line throws the following exception (see image)
All dependencies of the external assembly are also referenced in the main (WPF) application. So what's wrong here and how to fix it?