是否有可能從導入的MEF類型獲取程序集信息,而不實例化類型?我需要知道包含Type的插件控件的程序集名稱和版本。嘗試了以下,但它只是返回System.ComponentModel.Composition。如何通過MEF獲取導入的UserControl的程序集信息,而不實例化UserControl?
foreach (Lazy<UserControl, IMetadata> content in contents)
{
// get assembly information of the Plugin control for the imported function
string definingAssembly = content.GetType().Assembly.GetName();
Console.WriteLine(definingAssembly);
}
爲了儘可能避免維護問題,我想避免在元數據中指定這些信息。