Reputation: 17574
I'm building a GUI application framework using WPF in .NET 3.5.
My main application has very few dependencies. One of its jobs is to load external assemblies (plugins) and request windows and controls from them.
That part works fine.
Problems arise when a plugin uses a control not defined in the WPF framework. For example, I have a plugin that references the WPF Toolkit and uses a DatePicker
. When the main application reads the XAML file and sees DatePicker
, it throws an XAMLParseException
, stating
Cannot find type 'Microsoft.Windows.Controls.DatePicker'. The assembly used when compiling might be different than that used when loading and the type is missing.
It's obvious to me why this exception is being thrown, and adding a reference to the WPF Toolkit in the main application fixes the problem. But I won't be able to add references in the main application for every control used by a plugin, because I have no idea what those controls might be.
I'll also add that the main application loads plugins using Assembly.LoadFrom
.
Now for the questions:
Do I need to have the plugins copy their dependencies to the main application's directory, then load them as well? What are my other options? Has this issue been addressed somehow in .NET 4?
Upvotes: 0
Views: 456
Reputation: 194
did you try to put the WPF Toolkit dll's together with the plugin? another option is registering to the GAC
Upvotes: 0
Reputation: 22334
Not necessarily a good way, but ILMerge may work for you. When looking for that link I saw reference to this article which may work as well.
Upvotes: 1