'System.InvalidOperationException' occurred in Microsoft.Practices.Prism.dll, while navigate to request

StackOverflow https://stackoverflow.com/questions/17641619

  •  03-06-2022
  •  | 
  •  

Question

I get 'System.InvalidOperationException' occurred in Microsoft.Practices.Prism.dll

while i perform request to navigate. I navigate to a popup region. as first time when i invoke the command, view is getting loaded. but as i close the popup view and come back again to invoke, i get the above exception

this.regionManager.RequestNavigate(RegionNames.SecondaryRegion, new Uri(ViewNames.VW_SEC_SEARCH_SERVICE, UriKind.Relative));

what possibly causing this issue?

Was it helpful?

Solution

found the issue, that is caused due view is still persistent in region even though i closed it. i manually removed the views in that region and re-added again. that solved the problem

if (this.regionManager.Regions[RegionNames.SecondaryRegion] != null)
                {
                    List<object> views = new List<object>(this.regionManager.Regions[RegionNames.SecondaryRegion].Views);

                    foreach (object view in views)
                    {
                        this.regionManager.Regions[RegionNames.SecondaryRegion].Remove(view);
                    }
                }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top