Friday, July 02, 2004

Yet another bug on the .NET framework

I hit another bug on the .NET framework. No, this time the bug is not a leak like the other two times.
I have this application that is starting to work, and it's starting to be a cool visual credit policies MDI editor. Now that the grunt work is done, I started to make the application visually appealing, and I started adding some icons to the toolbars. Everything was ok, until I added a toolbar and an ImageList to the main MDI form. Suddenly, every image on every toolbar on the application disappeared!
What amazed me more was that at design time everything was ok. After a bit try this, disable that, I disabled the following line on my Main():
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
// Application.EnableVisualStyles(); <-- Removing this line "solved" the problem
Application.Run(new Principal());
}

Now I had something to search and after a bit of Google I found this article. Although there are some failure reports on the posts below, Don is right: simply adding an Application.DoEvents worked like a charm!

Comments:
While this IS a bug, it's only small, and the work around is simple. Just add Application.DoEvents() after the Appication.EnableVisualStyles() to ensure the operation completes before resuming.

regards

leppie
 
Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?