I register my module views in the Initialize method of module class in this way;
//CalendarModule.cs
public void Initialize()
{
_container.RegisterType<object, CalendarModuleView>(nameof(CalendarModuleView));
}
And I load my modules by calling ModuleManager.LoadModule("CalendarModule");
.
After module initialized, I navigate to my newly loaded module;
_regionManager.RequestNavigate(RegionNames.MainContentRegion, "CalendarModuleView");
So far there is no problem. Everythig works just I expected. I can navigate through all on-demand modules.
But when I try to replace view registration with _container.RegisterTypeForNavigation<CalendarModuleView>();
I get following error during module loading;
An exception of type 'Prism.Modularity.ModuleInitializeException' occurred in Prism.Wpf.dll but was not handled in user code
Additional information: An exception occurred while initializing module 'CalendarModule'.
Inner Exception: {"Could not load file or assembly 'Prism.Unity.Wpf, Version=6.2.0.0, Culture=neutral, PublicKeyToken=91a96d2a154366d8' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)":"Prism.Unity.Wpf, Version=6.2.0.0, Culture=neutral, PublicKeyToken=91a96d2a154366d8"}
I wonder if RegisterTypeForNavigation<T>
container extension method does the same work with RegisterType<object, T>(nameof(T))
container method. If yes, what causes preceeding error? Thanks!
FYI: My modules' initialization mode are OnDemand.
I use Prism.Unity as DI container.
CalendarModule
and the main application? If so, try updating the prism nuget packages for each one. – Domysee