イム、私が持っている:MEFのみロード輸出
var catalog = new AssemblyCatalog(typeof(Shell).Assembly);
var externalCatalog = new DirectoryCatalog(@".\Modules");
var container = new CompositionContainer(catalog);
var a = new AggregateCatalog(externalCatalog, catalog);
しかし、イムは、輸出を取得しよう:
CompositionContainer __container = new CompositionContainer(a);
//get all the exports and load them into the appropriate list tagged with the importmany
__container.Compose(batch);
var yyyy = __container.GetExports<IModule>();
外部アセンブリ "Rejseplan"で自分の "IPlugin"が見つかりません。
"Rejseplan" プラグインの実装:(ロードされないもの)
namespace Rejseplan
{
[ModuleExport(typeof(IPlugin), InitializationMode = InitializationMode.WhenAvailable)]
class RejseplanModule : IModule, IPlugin
{
private readonly IRegionViewRegistry regionViewRegistry;
[ImportingConstructor]
public RejseplanModule(IRegionViewRegistry registry)
{
this.regionViewRegistry = registry;
}
public void Initialize()
{
regionViewRegistry.RegisterViewWithRegion("MainRegion", typeof(Views.DepartureBoard));
}
string IPlugin.Name
{
get { throw new NotImplementedException(); }
}
string IPlugin.Version
{
get { throw new NotImplementedException(); }
}
string IPlugin.TabHeader
{
get { throw new NotImplementedException(); }
}
}
}
"テスト" プラグイン(ロードされるもの)のimplmentation:
namespace HomeSystem
{
[Export(typeof(IPlugin))]
[ModuleExport(typeof(IModule), InitializationMode = InitializationMode.WhenAvailable)]
public class Test : IModule, IPlugin
{
public void Initialize()
{
}
public string Name
{
get { return "Test"; }
}
public string Version
{
get { return "Tis"; }
}
public string TabHeader
{
get { return "Tabt"; }
}
}
}
皆さんお手伝い願います
乾杯! :)
エラーが表示されるのですか、カタログにプラグインが一覧表示されていませんか? – blindmeis
私のカタログのすべての部分を取得しました。私のプラグインのリストは、シェルDLL内のものだけを返します –
重要な注意点:dllがロードされ、プログラム内のその領域にモジュールが表示されます。うまく動作しますが、モジュールのインスタンスを取得してそのデータをシェルから取得することはできません - (私はモジュールに関するシェルにいくつかのデータを表示したい) –