0

In a program that was working, I started getting the following exception: Activation error occurred while trying to get instance of type IRegionNavigationService

The inner exception is InnerException {"The current type, CommonServiceLocator.IServiceLocator, is an interface and cannot be constructed. Are you missing a type mapping?"} System.Exception {System.InvalidOperationException}

Since this is part of the Prism 6 platform, I'm at a loss as to where to start to fix the problem.

The problem started when I was updating the project from a repository and the solution file became corrupted. I got the program to run, but when I choose an option that navigates to another view I get the exception.

Here is the code that gets the exception:

public class MainMenuViewModel : BindableBase, IRegionManagerAware
{
    public IRegionManager RegionManager { get; set; }


    public MainMenuViewModel()
    {
        CustomerProfileCommand = new DelegateCommand(ExecuteCustomerProfileCommand);
        AdjustmentTypeCommand = new DelegateCommand(ExecuteAdjustmentTypeCommand);
        StreetProfileCommand = new DelegateCommand(ExecuteStreetProfileCommand);
        LocationMaintenanceCommand = new DelegateCommand(ExecuteLocationMaintenanceCommand);
    }

    private void ExecuteLocationMaintenanceCommand()
    {
        RegionManager.RequestNavigate(RegionNames.ContentRegion, NavigationNames.LocationMaintenance);
    }

    private void ExecuteStreetProfileCommand()
    {
        RegionManager.RequestNavigate(RegionNames.ContentRegion, NavigationNames.StreetMaintenance);
    }

    private void ExecuteAdjustmentTypeCommand()
    {
        RegionManager.RequestNavigate(RegionNames.ContentRegion, NavigationNames.AdjustmentTypeMaintenance);
    }

    private void ExecuteCustomerProfileCommand()
    {
        RegionManager.RequestNavigate(RegionNames.ContentRegion, NavigationNames.CustomerProfile);
    }

    public ICommand  CustomerProfileCommand { get; set; }
    public ICommand AdjustmentTypeCommand { get; set; }
    public ICommand StreetProfileCommand { get; set; }
    public ICommand LocationMaintenanceCommand { get; set; }
}

The RegionManager is instantiated by a region behavior and (using debug to verify) is actually instantiated.

Any direction as to where I should start is appreciated.

Ken
  • 57
  • 1
  • 11

1 Answers1

0

OK, I found the problem. I had upgraded the CommonServiceLocator package to 2.03. Apparently, Prism 6.30 only works with version 1.3.0. After I made that change, the program worked.

Ken
  • 57
  • 1
  • 11
  • Thumbs up for solving your own problem. Also be aware that the current version of Prism (7.0) does support Unity 5, However, one of Prism's dependencies has not been updated to support Unity 5, so as a whole, you're also stuck with Unity 4.0 for now. – Adam Vincent Apr 27 '18 at 02:59
  • Yes, I’m aware of the new version of Prism, but I haven’t found any information on migrating from 6.3. So, for now, I’m sticking with what I’ve got. – Ken Apr 27 '18 at 14:42