0
votes

When my Prism 6 modular WPF application using Unity starts then 'System.Configuration.ConfigurationErrorsException' in System.Configuration.dll is thrown. This exception is announcing that "'Prism.Modularity.ModulesConfigurationSection' type from 'Prism' assembly could not be loaded" and it throws when UnityBootstrapper.Run method is called in App.config file. Below is screen shot of exception (I have MSVS 2015 russified)

enter image description here

Below is the my application's Bootstrapper class:

class Bootstrapper : UnityBootstrapper
{
    protected override DependencyObject CreateShell()
    {
        return Container.Resolve<MainWindow>();
    }

    protected override void InitializeShell()
    {
        Application.Current.MainWindow.Show();
    }

    protected override IModuleCatalog CreateModuleCatalog()
    {
        return new ConfigurationModuleCatalog();
    }
}

I register all modules in App.config file of the main project of the solution. Please se below:

<?xml version="1.0" encoding="utf-8" ?>
    <configuration>
        <configSections>
            <section name="modules" type="Prism.Modularity.ModulesConfigurationSection, Prism"/>
        </configSections>
        <modules>
            <module assemblyFile="Authorization.dll" moduleType="Authorization.AuthorizationModule, Authorization, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" moduleName="AuthorizationModule" startupLoaded="true" />
            <module assemblyFile="Calibration.dll" moduleType="Calibration.CalibrationModule, Calibration, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" moduleName="CalibrationModule" startupLoaded="true" />
        </modules>
        <startup>
            <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
        </startup>
    </configuration>

The main project was created with Prism Template Pack as Prism Unity App and the each module was created with Prism Template Pack as Prism Module. When my application starts then on the short moment (about 1 second) the application main window is displayed and after the above-mentioned exception is thrown. What should I correct in my application for eliminating the error? Please help.

2
After I change to: "<configSections> <section name="modules" type="Prism.Modularity.ModulesConfigurationSection, Prism.Wpf"/> </configSections>" the exception was eliminated. But .ModuleTypeLoadingException begins to throw.Dr.Doog

2 Answers

1
votes

I had the same error in a project. System.Configuration.ConfigurationErrorsException thrown, when program tried to access to settings.settings.

I fixed this issue thanks to StepUp answer. I have had to do this only on the start up project of my solution, despite error occurs on another project.

0
votes

One of the reason that I've met is when App.config file's Build Action is not set to "Resource". Try to set App.config file's Build Action to "Resource". (right click at App.config file and look at the properties, see Build Section).