More on SEHException

I blogged a couple weeks ago about a SEHException we were getting in our Public Sub Main due to Application.EnableVisualStyles. Basically the solution was to insert an Application.DoEvents after the EnableVisualStyles call. Well, that has been working until today (which happens to be the day I have to demo this to our owner). So I made EnableVisualStyles an option in the application. So now the code looks like this:

   If AppOptions.EnableVisualStyles = True Then
      Application.EnableVisualStyles()
   End If
   Application.DoEvents()
   Application.Run(New frmMain)
Catch exSEH As System.Runtime.InteropServices.SEHException
   AppOptions.EnableVisualStyles = False
   AppOptions.ToXML(OptionsXMLLocation)
   Application.DoEvents()
   MsgBox("Critical XP Styles Error" & Environment.NewLine & "Please reboot GPS Control Room", MsgBoxStyle.Critical)
   End

This article is part of the GWB Archives. Original Author: Tim Hibbard

New on Geeks with Blogs