Modules initialized after shell / clarification of init sequence #2417
Unanswered
the-black-wolf
asked this question in
WPF
Replies: 2 comments 3 replies
-
@brianlagunas any comments? |
Beta Was this translation helpful? Give feedback.
1 reply
-
I 've just rechecked the lifetime order of method calls in Prism.Wpf (8.1.97):
If your App uses a module view, and that view uses a module service in its viewModel constructor, It is problematic. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
This issue is also slightly related to issue #1601 - Prism.Wpf: InitializeModules() should be called even if there's no shell
Looking at this piece of code:
Prism/src/Wpf/Prism.Wpf/PrismApplicationBase.cs
Lines 76 to 85 in d8b8a7d
Is there any specific reason why modules are initialized after the shell? Why can't
InitializeModules
be before theCreateShell
and thus have all the type registrations be available insideCreateShell
override?I ask because I have a specific two-prong problem, one is configuration based ACL which affects the layout of the Shell and the other, more problematic, the localization. I could in theory postpone ACL application, but WPF is messed up in the sense that there is no easy way to reload/rebind the entire visual tree based on custom chosen locale. The moment you instantiate visual elements the WPF is set in its culture, and short of very hard to maintain schemes, the only way to change language is to restart the application and change UI and thread cultures BEFORE the first WPF.
Now, the source of the problem is that locale and ACL configuration gets dictated by business logic. One I have in a second module, one whose type registration did not yet happen when the Shell is created/initialized.
I could be missing a bigger picture, but I find this order of init needlessly prohibitive. Especially since main module types do get registered before shell, and so does the registration of modules (both
RegisterTypes
andConfigureModuleCatalog
are executed before theCreateShell
. Issue #1601 addressed the shell-less mode, but it seems to have positioned the module initialization to a wrong point.Beta Was this translation helpful? Give feedback.
All reactions