开发者

What might cause an ArgumentException (Given combination of Class, Part, and State is not defined by the current visual style)?

开发者 https://www.devze.com 2023-02-08 19:43 出处:网络
I have a C++/CLI .net application and I encountered a peculiar exception the other day (see below). I\'m running on Windows XP Embedded if that makes a difference. What might cause this as it doesn\'t

I have a C++/CLI .net application and I encountered a peculiar exception the other day (see below). I'm running on Windows XP Embedded if that makes a difference. What might cause this as it doesn't directly relate to any of my own code?

Exception:
   开发者_如何学编程 Given combination of Class, Part, and State is not defined by 
    the current visual style.
Exception type:
    System.ArgumentException
Source:
    System.Windows.Forms
Stack trace:
    at System.Windows.Forms.VisualStyles.VisualStyleRenderer..ctor(
        String className, Int32 part, Int32 state)
    at System.Windows.Forms.ButtonRenderer.InitializeRenderer(Int32 state)
    at System.Windows.Forms.ButtonRenderer.IsBackgroundPartiallyTransparent(
        PushButtonState state)
    at System.Windows.Forms.ButtonInternal.ButtonStandardAdapter.
        PaintThemedButtonBackground(PaintEventArgs e, Rectangle bounds, 
        Boolean up)
    at System.Windows.Forms.ButtonInternal.ButtonStandardAdapter.
        PaintWorker(PaintEventArgs e, Boolean up, CheckState state)
    at System.Windows.Forms.ButtonInternal.ButtonStandardAdapter.
        PaintUp(PaintEventArgs e, CheckState state)
    at System.Windows.Forms.ButtonInternal.ButtonBaseAdapter.Paint(
        PaintEventArgs pevent)
    at System.Windows.Forms.ButtonBase.OnPaint(PaintEventArgs pevent)
    at System.Windows.Forms.Control.PaintWithErrorHandling(
        PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)
    at System.Windows.Forms.Control.WmPaint(Message& m)
    at System.Windows.Forms.Control.WndProc(Message& m)
    at System.Windows.Forms.ButtonBase.WndProc(Message& m)
    at System.Windows.Forms.Button.WndProc(Message& m)
    at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(
        Message& m)
    at System.Windows.Forms.Control.ControlNativeWindow.WndProc(
        Message& m)
    at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, 
        Int32 msg, IntPtr wparam, IntPtr lparam)

    Installed .net Versions:
        v2.0.50727


This comes straight out of Windows, the IsThemePartDefined() API function. What's significant about this function is that it doesn't have any way to report an error, it can only return TRUE or FALSE. A possible failure mode here is that it may run into some kind of internal error and can only reasonably return FALSE. That's a kaboom in Winforms.

These kind of 'runs for days, then crashes' kind of errors do have an almost universal reason. The process has exhausted one of the Windows resources quotas. Pretty typical when your app is leaking handles. The first order diagnostic for this is looking at the resources used by your app from the Taskmgr.exe Processes tab. View + Select Columns and tick Handles, USER objects and GDI objects.

0

精彩评论

暂无评论...
验证码 换一张
取 消