我正在使用MEF創建插件樣式體系結構,但是我得到了組合異常。無法從部分導出
這裏是細節。
我有以下代碼:
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))
{
}
}
就行了:
if (!this.pluginDictionary.ContainsKey(plugin.Value.ModuleName))
我得到下面的異常拋出:
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.
這是所有工作的話,我改變了我插件從System.Windows.Window類繼承。這是否會導致失敗?
赫雷什插件頭:
[Export(typeof(IGX3PluginInterface))]
public partial class MainWindow : GX3ClientPlugins.GX3ClientPlugin
凡GX3ClientPlugin延伸System.Windows.Window類。
Im相當肯定這是相關但不完全yunderstand吧:) http://mef.codeplex.com/discussions/81717
請讓我知道你需要什麼其他信息?
謝謝你會檢查這些並回復給你 – user589195