I have come across this issue while working with WPF application using prism. I got to know what the error was, but couldn't find out why was this error and when can the region be null for any object. Want to know how such issues can be handled in the
application so that they do not occur again.
Details of the issue:
The cause of this issue was that some code in the application called Microsoft.Practices.Prism.Regions.Behaviors.DelayedRegionCreationBehavior.CreateRegion(System.Windows.DependencyObject, System.String), but supplied a null for the String argument, which appears
to be the "regionName".
While creating region, the prism code is trying to get RegionName from the dependency object which is a null value and because of this the Initialize method is throwing ArgumentNull exception.
The most likely causing exception was: 'System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Microsoft.Practices.Prism.Regions.Behaviors.RegionCreationException: An exception occurred while creating
a region with name ''. The exception was: System.ArgumentNullException: Value cannot be null.
Parameter name: regionName
1.Initialize(T regionTarget, String regionName)
1.Microsoft.Practices.Prism.Regions.IRegionAdapter.Initialize(Object regionTarget, String regionName)
at Microsoft.Practices.Prism.Regions.Behaviors.DelayedRegionCreationBehavior.CreateRegion(DependencyObject targetElement, String regionName). ---> System.ArgumentNullException: Value cannot be null.
Feb 28, 2013 at 4:46 PM
Edited Feb 28, 2013 at 4:48 PM
I manage to reproduce the exception by setting a region name to ""
(empty), using the following code snippet in my view:
<ContentControl cal:RegionManager.RegionName="" />
Therefore, I would recommend you to check that all the regions in your views are correctly named and that you don't have any empty region name. If that is not the case, it would be useful if you could provide us with more information on how you are defining
regions in your views.
I hope you find this useful,