Friday, 15 January 2010

c# - Windows Form throws Visual Styles-related exception mid-execution -


I have a window form that normally runs without a problem, but every time (& lt; time 1%) me such an error appears:

view was an error resulting from style-related operations as a visual style is not currently active System.Windows.Forms.VisualStyles in. VisualStyleRenderer.get_Handle () on System.wondo.form.vijual style.vidual styleRenderer.draBagelGen (IDeviceContextDes Border rectangle, rectangle Klipreksel) system Prkvindokform. GroupBanderendor.Draw GroupsGroupsBacksweed Text (Graphics G, Rectangle Borders, String GroupBoxText, Font Font, TextFormatFlags, Graphics G, Rectangle Borders, String GroupBoxText, Font Font, Color Textcolor, TextFormatFlags Flags, GroupBoxState State) on System.Windows.Forms.GroupBoxRenderer.DrawGroupBox Flags, GroupBoxState State) on systems. Windows.Forms.GroupBox.OnPaint (PaintEventArgs e) System.Windows.Forms.Control.PaintWithErrorHandling (PaintEventArgs E, int16 layer) SystemkWindows on (message System.Windows.Forms.Control.WmPaint & amp; M). On Forms In ControlkWndProc (Message & amp; M) in (message System.Windows.Forms.GroupBox.WndProc & amp; M) in (message System.Windows.Forms.Control.ControlNativeWindow.OnMessage & amp; M) System W ndProc (message .Windows.Forms.Control.ControlNativeWindow & amp; System.Windows.Forms.NativeWindow.Callback (IntPtr hWnd, Int32 message, IntPtr wParam, IntPtr lParam) m)

I have introduced the first visual styles with errors, so that the machine that uses the app has compatible desktop themes. What's strange with this error is that the program starts The audience and runs happily for some time (eg 30 minutes) before the exception is thrown. I can not understand how the visual style can change during state execution.

The application that uses a Windows form, loads of web pages and responds to JavaScript callback, which is composed of a console application that launches.

I've been listening Thread Apeshn Aventhandlr on the console app application.ThreadException I it possibly Windows form that happened to me The settlement happened when the error occurred, but I do not think this is the case, because when I log this error, I can access examples of example examples. myForm.ToString ()

Since none of my code is shown in stack trace, I'm not sure what else would be helpful in describing this error. Has anyone seen anything like this before doing this?

After

Hans Passant was right, it was a GDI handle leak. I could not reproduce it on my development environment, so it was necessary to add some logging to my server if it helps someone else, so here's what information I need to implement the function .

and its use to get the handle count:

  var p = Process.GetCurrentProcess (); Kernel = p.HandleCount; GdiObjects = GetGuiResources (P. Handel, 0); UserObjects = GetGuiResources (P. Handel, 1); GdiObjectsPeak = GetGuiResources (P. Handel, 2); UserObjectsPak = GetGuiResources (P. Handel, 4);   

Once this happened, I saw that the GDI objects were at the limit of 10,000 on the crash.

No comments:

Post a Comment