大氣壓在我的應用我這樣做:負載棱鏡模塊(在啓動時)
class Bootstrapper : UnityBootstrapper
{
protected override DependencyObject CreateShell()
{
return Container.Resolve<Shell>();
}
protected override void InitializeShell()
{
base.InitializeShell();
App.Current.MainWindow = (Window)Shell;
App.Current.MainWindow.Show();
}
protected override void ConfigureModuleCatalog()
{
base.ConfigureModuleCatalog();
var moduleCatalog = (ModuleCatalog)ModuleCatalog;
moduleCatalog.AddModule(typeof(FooModule));
moduleCatalog.AddModule(typeof(BarModule));
}
}
我想負載FooModule和BarModule通過指示DLL文件的路徑,像這樣的:
protected override void ConfigureModuleCatalog()
{
...
var assembly = Assembly.LoadFrom(@"libs\FooLib.dll");
var type = assembly.GetType("FooLib.FooModule");
moduleCatalog.AddModule(type);
...
}
,但它不工作,我得到這個錯誤信息上Bootstrapper.Run():
有銅在ModuleManager中rrently沒有moduleTypeLoader,它可以檢索指定的模塊。
編輯: 這是我FooModule:
public class FooModule : IModule
{
private readonly IRegionViewRegistry _regionViewRegistry;
public FooModule(IRegionViewRegistry registry)
{
_regionViewRegistry = registry;
}
public void Initialize()
{
_regionViewRegistry.RegisterViewWithRegion("MainRegion", typeof(Main));
}
}
非常感謝你,它工作! – Omu 2012-04-04 07:44:31