I was getting a nasty error today. I built a tabcontrol component and docked (fill) it on a form with a statusbar. Whenever I moved my mouse from the component to the statusbar, I got this exception:
Class:System.Runtime.InteropServices.SEHException
Message: External component has thrown an exception.
The exception occurred in the method that called Application.Run, and it would end the application after the exception was handled. After some googling, I learned that it was because I did not call Application.DoEvents after Application.EnableVisualStyles. I have never read that before, so hopefully this helps somebody.
So now my code reads:
Application.EnableVisualStyles()
Application.DoEvents()
Application.Run(New frmMain)
Here are some more links about it:
http://www.codeguru.com/forum/showthread.php?p=1036531
http://www.mctainsh.com/Csharp/EnableVisualStylesIsEvil.aspx