【发布时间】:2012-04-02 09:03:58
【问题描述】:
我的应用程序中的 Atm 我喜欢这样:
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));
}
}
我想通过指示 dll 文件的路径来加载 FooModule 和 BarModule,如下所示:
protected override void ConfigureModuleCatalog()
{
...
var assembly = Assembly.LoadFrom(@"libs\FooLib.dll");
var type = assembly.GetType("FooLib.FooModule");
moduleCatalog.AddModule(type);
...
}
但它不起作用,我在 Bootstrapper.Run() 上收到此错误消息:
ModuleManager中目前没有可以获取指定模块的moduleTypeLoader。
编辑: 这是我的 FooModule:
public class FooModule : IModule
{
private readonly IRegionViewRegistry _regionViewRegistry;
public FooModule(IRegionViewRegistry registry)
{
_regionViewRegistry = registry;
}
public void Initialize()
{
_regionViewRegistry.RegisterViewWithRegion("MainRegion", typeof(Main));
}
}
【问题讨论】: