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)
http://img41.imageshack.us/img41/2261/7xvqv.png http://img41.imageshack.us/img41/2261/7xvqv.png
All dependencies of the external assembly are also referenced in the main (WPF) application. So what's wrong here and how to fix it?