내 앱으로 가져 오는 MEF 플러그인 컨트롤을 만들었습니다. 이제 플러그인이 앱에서 부품을 가져올 수있게하려고합니다. 플러그인에서 카탈로그를 설정하는 방법을 알 수 없으므로 앱에서 내보내기를 찾을 수 있습니다. 누군가 어떻게 이것이 이루어 졌는지 말해 줄 수 있습니까? 아래는 현재 실행중인 어셈블리로 AssemblyCatalog를 만들려고 할 때 작동하지 않는 코드입니다.MEF : 내 보낸 개체에서 가져 오는 방법?
[Export(typeof(IPluginControl))]
public partial class MyPluginControl : UserControl, IPluginControl
[Import]
public string Message { get; set; }
public MyPluginControl()
{
InitializeComponent();
Initialize();
}
private void Initialize()
{
AggregateCatalog catalog = new AggregateCatalog();
catalog.Catalogs.Add(new AssemblyCatalog(Assembly.GetExecutingAssembly()));
CompositionContainer container = new CompositionContainer(catalog);
try
{
container.ComposeParts(this);
}
catch (CompositionException ex)
{
Console.WriteLine(ex.ToString());
}
}
}
감사합니다. 도움을 준 모든 것이 도움이되었으며 지금 작동합니다! –