I am using MEF to create a plugin style architecture, but Im getting a composition exception.
Here is the detail.
I have the following code:
AggregateCatalog catalog = new AggregateCatalog();
catalog.Catalogs.Add(new DirectoryCatalog(pluginDirectory));
CompositionContainer container = new CompositionContainer(catalog);
container.ComposeParts(this);
// add to dictionary
foreach (Lazy<IGX3PluginInterface> plugin in plugins)
{
if (!this.pluginDictionary.ContainsKey(plugin.Value.ModuleName))
{
}
}
On the line:
if (!this.pluginDictionary.ContainsKey(plugin.Value.ModuleName))
I get the following exception thrown:
Exception = {"The composition produced a single composition error. The root cause is provided below. Review the CompositionException.Errors property for more detailed information. 1) The calling thread must be STA, because many UI components require this.
This was all working then I changed my plugin to inherit from the System.Windows.Window class. Could this be causing the failure?
Heres the plugin header:
[Export(typeof(IGX3PluginInterface))]
public partial class MainWindow : GX3ClientPlugins.GX3ClientPlugin
Where GX3ClientPlugin extends the System.Windows.Window class.
Im pretty sure this is relevant but dont full yunderstand it :) http://mef.codeplex.com/discussions/81717
Please let me know what other information you require?