In my Bootstrapper constructor, I am setting up a few things. Determining the environment (DEV,TEST,PROD), getting the connection string, finding the current user in the DB, etc.
I am checking for user access also. So if the user attempting to use the application does not exist in the database or does not have access, I want to pop up a message, and then exit the application.
So in my constructor, I am simply doing this for now:
if (User == null)
System.Windows.MessageBox.Show("Sorry, you do not have access to this app.");
I will not be using a MessageBox once I am finished, but this is just the prototype. The problem is, once it hits the MessageBox line, it immediately tries to run this from the CM Bootstrapper class:
protected virtual void OnStartup(object sender, StartupEventArgs e)
Which results in this error, because it cannot create the Shell instance:
The composition produced a single composition error. The root cause is provided below. Review the CompositionException.Errors property for more detailed information.
1) Object reference not set to an instance of an object.
Resulting in: Cannot get export 'WindowsClients.MyApp.ViewModels.ShellViewModel
Am I just going about this the wrong way for displaying a message to the user? My goal is to display a message to the user before it even tries to load the Shell view, and then exit the app. I am running into the same problem when there is any kind of error
in the Bootstrapper, and I am trying to display another MessageBox to display the Error Message. Then the app needs to exit.