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 8415083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:20:41+00:00 2026-06-10T01:20:41+00:00

In my Caliburn Bootstrapper, I am trying to validate that a user has permissions

  • 0

In my Caliburn Bootstrapper, I am trying to validate that a user has permissions to run my application. If they do not, I need to present them with a message and exit. The following code throws a NullReferenceException on the MessageBox.Show() call. Even if I move the ComposeMef() call before the ValidateUserHasPermissionsToRun() in the Configure() method, it still errors.

public class MyBootstrapper : Bootstrapper<DropWindowViewModel>
{

   // irrelevant methods omitted for brevity

   protected override void Configure()
   {
      this.InitializeSecurity();
      this.ValidateUserHasPermissionToRun();
      this.ComposeMef();
   }

   private void ComposeMef()
   {
      AggregateCatalog catalog = new AggregateCatalog(AssemblySource.Instance.Select(x => new AssemblyCatalog(x)).OfType<ComposablePartCatalog>());

      this.container = new CompositionContainer(catalog);

      CompositionBatch batch = new CompositionBatch();

      batch.AddExportedValue<IWindowManager>(new WindowManager());
      batch.AddExportedValue<IEventAggregator>(new EventAggregator());
      batch.AddExportedValue(this.container);
      batch.AddExportedValue(catalog);

      this.container.Compose(batch);
   }      

   private void ValidateUserHasPermissionToRun()
   {
      User user = SecurityContext.Current.SecurityUser;

      if (!user.HasPrivilege(Constants.PrivilegeLoadData))
      {
         // throws an exception
         MessageBox.Show("You do not have access to VIPER. Please contact the help desk if you need help.");
         this.TerminateApplication();
      }
   }
}

What is the proper way to handle this? For something this simple, I just want to show a message box. I don’t really want to get into composing a whole new ViewModel/View. If I have to use a different ViewModel, how would I switch which ViewModel Caliburn uses? Or should I set a property on the DropWindowViewModel to trigger a different interface?

  • 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-06-10T01:20:42+00:00Added an answer on June 10, 2026 at 1:20 am

    I’d suggest this is something that should be done within your root viewmodel. The bootstrapper should be just that. It loads the resources needed for your app & configures them. After that it’s done. Checking whether the user can run the app is part of your application logic & should therefore go in the root viewmodel.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application that uses Caliburn.Micro. My View contains a user control which
I have a wpf application using Caliburn.Micro. I need to bind a ListBox to
I have a wpf application using caliburn.micro. It has a datagrid and a combobox.
I'm using Caliburn and the MVVM pattern in a WPF application, and am trying
I'm trying to understand the HelloScreens sample that comes with Caliburn.Micro . The ShellView.xaml
We're starting a new Silverlight project on Caliburn.Micro. We need to log every user
I have a Caliburn.Micro application that runs on some rather slow panel PCs. The
In my WPF Caliburn.Micro application, I have a datagrid and a checkbox with a
I use the Caliburn Micro framework. That doesn't actually matter. The point is, that
I'm a newcomer to Caliburn.Micro and there are a few things I'm still not

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.