Losing RegionAdapter mappings using Microsoft.DI extensions...
See original GitHub issueWe can get constructor injection working with the following.
protected override IContainerExtension CreateContainerExtension() => PrismContainerExtension.Init();
protected override void RegisterTypes(IContainerRegistry containerRegistry)
{
containerRegistry = containerRegistry.RegisterServices(svc =>
{
MyApplication.DependencyInjection.AddApplication(svc);
});
}
The IRegionAdapter for the type System.Windows.Controls.ContentControl is not registered
Prism.Regions.UpdateRegionsException: 'An exception occurred while trying to create region objects.
- The most likely causing exception was: 'System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> Prism.Regions.Behaviors.RegionCreationException: An exception occurred while creating a region with name 'SidePanelRegion'. The exception was: System.Collections.Generic.KeyNotFoundException: The IRegionAdapter for the type System.Windows.Controls.ContentControl is not registered in the region adapter mappings. You can register an IRegionAdapter for this control by overriding the ConfigureRegionAdapterMappings method in the bootstrapper.
at Prism.Regions.RegionAdapterMappings.GetMapping(Type controlType)
at Prism.Regions.Behaviors.DelayedRegionCreationBehavior.CreateRegion(DependencyObject targetElement, String regionName).
---> System.Collections.Generic.KeyNotFoundException: The IRegionAdapter for the type System.Windows.Controls.ContentControl is not registered in the region adapter mappings. You can register an IRegionAdapter for this control by overriding the ConfigureRegionAdapterMappings method in the bootstrapper.
at Prism.Regions.RegionAdapterMappings.GetMapping(Type controlType)
at Prism.Regions.Behaviors.DelayedRegionCreationBehavior.CreateRegion(DependencyObject targetElement, String regionName)
--- End of inner exception stack trace ---
at Prism.Regions.Behaviors.DelayedRegionCreationBehavior.CreateRegion(DependencyObject targetElement, String regionName)
at Prism.Regions.Behaviors.DelayedRegionCreationBehavior.TryCreateRegion()
at Prism.Regions.Behaviors.DelayedRegionCreationBehavior.OnUpdatingRegions(Object sender, EventArgs e)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Delegate.DynamicInvokeImpl(Object[] args)
at Prism.Events.WeakDelegatesManager.Raise(Object[] args)
at Prism.Regions.RegionManager.UpdateRegions()'.
But also check the InnerExceptions for more detail or call .GetRootException(). '
After overriding the ConfigureRegionAdapterMappings
we can see the mappings there after invoking the base method.
Not sure where these get lost? The app works as it should using Unity.
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (3 by maintainers)
Top Results From Across the Web
No regions in regionmanager using Microsoft Dependency ...
I am using the Microsoft Dependency Injection for DI. I don't want use Unity container. regionAdapterMappings is empty. View discovery and view ...
Read more >Untitled
Prism.Regions.RegionAdapterMappings.html Create a Custom Prism RegionAdapter - Brian Lagunas WebNamespace: Microsoft.Practices.Prism.MefExtensions.
Read more >Configuration in ASP.NET Core
Learn how to use the Configuration API to configure AppSettings in an ASP.NET Core app.
Read more >Essential .NET - Dependency Injection with .NET Core
In this article. Why Dependency Injection? .NET Core Microsoft.Extensions.DependencyInjection; Service Lifetime; Dependency Injection for the DI Implementation ...
Read more >13.4 Dependency Injection Support - OData
As we internally maintain a dictionary to map the route name to its corresponding root container (1-1 mapping), multiple OData routes (i.e., ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@hippieZhou, it seems to me, that it doesn’t work at all. Probably, it’s better to use another container.
Instead of using this package, since it doesn’t work…, I just wrote some static functions, where I can register services… Basicly I make use of the generic container to register the services, and then I copy them over to prism container.
Followed by using it in app.xaml.cs …