我們正在使用Catel.MVVM開發GUI插件框架。 應使用「ServiceLocatorRegistration」屬性動態加載單個插件。Catel自動註冊多個實例的屬性
例子:
[ServiceLocatorRegistration(typeof(IInitializable), ServiceLocatorRegistrationMode.SingletonInstantiateWhenRequired, "SamplePlugin")]
在我們的引導程序,我們所有的插件組件加載到默認的AppDomain:通過調用
var initializables = ServiceLocator.Default.ResolveTypes();
foreach(var initializable in initializables)
initializable.Initialize();
但即使
Catel.Windows.Controls.MVVMProviders.Logic.UserControlLogic.DefaultSkipSearchingForInfoBarMessageControlValue = true;
Catel.Windows.Controls.MVVMProviders.Logic.UserControlLogic.DefaultCreateWarningAndErrorValidatorForViewModelValue = false;
IoCConfiguration.DefaultServiceLocator.AutoRegisterTypesViaAttributes = true;
IoCConfiguration.DefaultServiceLocator.CanResolveNonAbstractTypesWithoutRegistration = true;
foreach (
var file in
BaseDirectory.GetFiles("*.dll", SearchOption.AllDirectories)
.Where(f => IsNetAssembly(f.FullName))
.Where(f => !f.FullName.EndsWith("resources.dll"))
.AsParallel())
{
try
{
var asm = Assembly.ReflectionOnlyLoadFrom(file.FullName);
}
catch { }
}
然後,我們嘗試對它們進行初始化我們有在AppDomain中加載的插件程序集,我們沒有得到所有具有ServiceLocatorRegistration的類貢。
是否有任何解決所有具有上述示例屬性設置的類? 在此先感謝!
我會嘗試儘快(第一次),但正如我寫的 - 我們已經加載到默認的AppDomain程序集。 我在上面的問題中添加了相應的代碼。 問題可能是我們加載了組件「ReflectionOnly」? – chrisih