<8/18/2004 update:  see part II of this post, with a better solution: http://weblogs.asp.net/asanto/archive/2004/08/18/216825.aspx >

.Net version 1.1 has a bug with XP Visual Styles which causes the following cryptic exception: "'System.Runtime.InteropServices.SEHException: External component has thrown an exception". This exception is trapped in the main application message loop (in a winform this is typically "Application.Run(new Form1());" ) which really doesn't help when trying to debug.  It turns out that this is a known bug which has been written up in many a blog: Scott HanselmanJeff Key, Aaron Z.   

Most blogs recommend either adding a DoEvents() in the code immediately after the EnableVisualStyles() command, or to skip the EnableVisualStyles() altogether and instead use an XML manifest to enable XP themes.  The DoEvents() didn't work for me at all (my app still crashed, just a bit deeper inside the UI) and I'm not willing to even think about using an XML manifest.

The solution I came up is:

[STAThread]
static void Main()
{
    Application.EnableVisualStyles();
     
new Thread(new ThreadStart(AppRun)).Start();
}

private static void AppRun()
{
   Application.Run(
new MainForm());
}

To be honest, this code sort of scares me. It works (so far) but I can't explain exactly why.  Help ??!?