Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7500739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T20:17:10+00:00 2026-05-29T20:17:10+00:00

I am using a Prism UnityExtensions bootstrapper class to start my WPF application. How

  • 0

I am using a Prism UnityExtensions bootstrapper class to start my WPF application. How do I shutdown the application while the unityextensions bootstrapper is still running?

See my bootstrapper class below. The SomeClass object may throw a custom exception (fatal). If the custom exception is thrown, I need to close the application. I am using Application.Current.Shutdown() to shutdown the application.

However, the bootstrapper code continues running, and I get a “ResolutionFailedException was unhandled” exception error when setting the datacontext in the CreateShell() method. Obviously, the SomeClass method and interface were not registered with the container due to the catch block.

It appears that the bootstrapper code continues running after a call to Application.Current.Shutdown() was called. I need to stop the bootstrapper code immediately following the call to shutdown.

Any ideas how to shutdown the application without creating the ResolutionFailedException?

ResolutionFailedException exception details –>
Resolution of the dependency failed, type = “SomeClass”, name = “(none)”.
Exception occurred while: while resolving.
Exception is: InvalidOperationException – The current type, SomeClass, is an interface and cannot be constructed. Are you missing a type mapping?

public class AgentBootstrapper : UnityBootstrapper
{
  protected override void ConfigureContainer()
  {
     base.ConfigureContainer();

     var eventRepository = new EventRepository();
     Container.RegisterInstance(typeof(IEventRepository), eventRepository);

     var dialog = new DialogService();
     Container.RegisterInstance(typeof(IDialogService), dialog);

     try
     {
        var someClass = new SomeClass();
        Container.RegisterInstance(typeof(ISomeClass), SomeClass);
     }
     catch (ConfigurationErrorsException e)
     {
        dialog.ShowException(e.Message + " Application shutting down.");
        **Application.Current.Shutdown();**
     }
  }

  protected override System.Windows.DependencyObject CreateShell()
  {
     var main = new MainWindow
     {
        DataContext = new MainWindowViewModel(Container.Resolve<IEventRepository>(),
                                              Container.Resolve<IDialogService>(),
                                              Container.Resolve<ISomeClass>())
     };

     return main;
  }

  protected override void InitializeShell()
  {
     base.InitializeShell();
     Application.Current.MainWindow = (Window)Shell;
     Application.Current.MainWindow.Show();
  }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T20:17:13+00:00Added an answer on May 29, 2026 at 8:17 pm

    This behaviour occurs, because you´re executing the OnStartup of your Application at this time. I suppose you do it like that:

    protected override void OnStartup(StartupEventArgs e)
    {
        new AgentBootstrapper().Run();
    }
    

    The OnStartup has to be completed, before the App can shutdown, so the bootstrapper continues execution. You might throw another exception to get out of the Run():

     ... catch (ConfigurationErrorsException e)
     {
        dialog.ShowException(e.Message + " Application shutting down.");
        throw new ApplicationException("shutdown");
     }
    

    And then catch it in the StartUp():

    protected override void OnStartup(StartupEventArgs e)
    {
        try
        {
            new AgentBootstrapper().Run();
        }
        catch(ApplicationException)
        {
            this.Shutdown();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We were building out the next version of an in-house thick-client application using WPF/Prism
I am creating an application using WPF which is using Prism framework. I have
I have an application which I am developing using WPF\Prism\MVVM. All is going well
I 'm using PRISM and in the Bootstrapper class i did override the ConfigureContainer()
We have the beginnings of a modular wpf application built using prism. We want
I'm creating an application silverlight 5 using prism 4 and when I'm running the
I have a Main WPF application and other modules and I am using PRISM
I'm writing a WPF application using a MVVM pattern and using Prism in selected
Using WPF and Prism. I have a view, containing 1 textblock <UserControl x:Class=ArmoryModule.Views.ResultsView xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation
I start using WPF with PRISM and MVVM. One problem I am facing is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.