Silverlight Prism 模块未就绪

发布于 2024-09-05 05:10:45 字数 643 浏览 5 评论 0原文

我正在使用 Prism(又名复合应用程序指南)构建 Silverlight 4.0 应用程序。我有两个模块,均在我的 ModuleCatalog.xaml 中定义为 WhenAvailable。我的 Application_OnStart 实例化我的 Bootstrapper 并调用它的 Run() 方法。在我的应用程序启动并运行后(事实上,用户必须单击 UI 中的按钮),我然后尝试加载模块:

foreach (ModuleInfo mi in moduleCatalog.Modules)
    ...
    Type moduleType = Type.GetType(mi.ModuleType); // moduleType ends up null!

有时,moduleType 最终为 null。我已经验证,当我遇到 null 时,ModuleInfo 的 StateLoadingTypes 而不是 ReadyForInitialization。我认为这意味着它仍在为我的模块下载单独的 *.xap 文件并将其类型带入应用程序域。

那我能做什么呢?如果我知道有一些事件我可以听并知道它们终于全部加载,我会很乐意阻止。

I'm building a Silverlight 4.0 application with Prism (a.k.a. Composite Application Guidance). I have two modules, both defined in my ModuleCatalog.xaml as WhenAvailable. My Application_OnStart instantiates my Bootstrapper and invokes it's Run() method. Well after my application is started and up and running (in fact, the user has to click a button in the UI), I then attempt to load the modules:

foreach (ModuleInfo mi in moduleCatalog.Modules)
    ...
    Type moduleType = Type.GetType(mi.ModuleType); // moduleType ends up null!

Sometimes, moduleType ends up null. I've verified that when I encounter the null, the ModuleInfo's State is LoadingTypes not ReadyForInitialization. I assume this means it's still downloading the separate *.xap files for my modules and bringing their types into the application domain.

So what can I do? I'd happily block if I knew there was some event I could listen to to know they're finally all loaded.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

找个人就嫁了吧 2024-09-12 05:10:46

如果您打算使用 Prism,则不应绕过它并自行创建模块。这不是 Prism 应该的工作方式。 Prism 不提供加载完成事件,因为这不是您应该需要做的事情。

简单情况:

如果您定义了一个模块目录,那么所有这些模块将逐步加载,因此在这种简单情况下无需手动加载任何模块。您可以在根 Silverlight 应用程序中创建一个具有一些模块依赖项的启动模块,这足以在加载应用程序的其余部分时使第一页可见。

需要更多信息:

我无法从上面的代码片段中看出您实际上想要完成什么,因此更多信息会有所帮助,但您应该使用 Unity 来解析接口,而不是直接使用 Type.GetType() 。您通常不需要解析模块本身,并且还有在 Prism 中触发按需加载的方法(目前手头没有它们......将更新它)。

谢谢:

您无意中提供了答案的线索 我在 Stack Overflow 中提出的另一个问题,非常感谢。

If you are going to use Prism, you should not bypass it and create your modules yourself. That is not the way Prism is supposed to work. Prism does not provide an event for load completion as that is not something you should need to do.

Simple case:

If you define a module catalogue then all those modules will be loaded progressively, so no need to load any manually in that simple case. You can create a start-up module in your root Silverlight app with a few module dependencies and that will be enough to get the first page visible while to rest of the app loads.

More info needed:

I can't tell what you are actually trying to accomplish from the above snippet, so more information would help, but you should be using Unity to resolve interfaces and never Type.GetType() directly. Your generally should not need to resolve a module itself and there are also methods for triggering load-on-demand loading in Prism (don't have them handy at the moment... will update this).

Thanks:

Your have accidentally provided a clue to the answer to another question I asked in Stack Overflow so thanks for that.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文