什么可能导致 ArgumentException(给定的类、部件和状态的组合不是由当前视觉样式定义的)?
我有一个 C++/CLI .net 应用程序,前几天遇到了一个特殊的异常(见下文)。我正在 Windows XP Embedded 上运行(如果这有什么区别的话)。由于它与我自己的任何代码没有直接关系,可能会导致此问题的原因是什么?
<前><代码>异常: 类、部件和状态的给定组合不是由 当前的视觉风格。 异常类型: 系统参数异常 来源: 系统.Windows.窗体 堆栈跟踪: 在 System.Windows.Forms.VisualStyles.VisualStyleRenderer..ctor( String className、Int32 部分、Int32 状态) 在 System.Windows.Forms.ButtonRenderer.InitializeRenderer(Int32 状态) 在 System.Windows.Forms.ButtonRenderer.IsBackgroundPartiallyTransparent( PushButtonState 状态) 在 System.Windows.Forms.ButtonInternal.ButtonStandardAdapter。 PaintThemedButtonBackground(PaintEventArgs e, 矩形边界, 布尔向上) 在 System.Windows.Forms.ButtonInternal.ButtonStandardAdapter。 PaintWorker(PaintEventArgs e, Boolean up, CheckState 状态) 在 System.Windows.Forms.ButtonInternal.ButtonStandardAdapter。 PaintUp(PaintEventArgs e, CheckState 状态) 在 System.Windows.Forms.ButtonInternal.ButtonBaseAdapter.Paint( PaintEventArgs pevent) 在 System.Windows.Forms.ButtonBase.OnPaint(PaintEventArgs pevent) 在 System.Windows.Forms.Control.PaintWithErrorHandling( PaintEventArgs e,Int16 层,布尔 disposeEventArgs) 在 System.Windows.Forms.Control.WmPaint(Message&m) 在 System.Windows.Forms.Control.WndProc(Message&m) 在 System.Windows.Forms.ButtonBase.WndProc(Message&m) 在 System.Windows.Forms.Button.WndProc(Message&m) 在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage( 留言&米) 在 System.Windows.Forms.Control.ControlNativeWindow.WndProc( 留言&米) 在 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg、IntPtr wparam、IntPtr lparam) 安装的.net版本: v2.0.50727
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这直接来自 Windows IsThemePartDefined() API 函数。这个函数的重要之处在于它没有任何方法报告错误,它只能返回 TRUE 或 FALSE。这里可能的失败模式是它可能会遇到某种内部错误并且只能合理地返回 FALSE。这就是 Winforms 中的一个热门话题。
这种“运行几天,然后崩溃”的错误确实有一个几乎普遍的原因。该进程已耗尽 Windows 资源配额之一。当您的应用程序泄漏句柄时非常典型。对此的第一个诊断顺序是从 Taskmgr.exe 进程选项卡查看应用程序使用的资源。查看 + 选择列并勾选句柄、USER 对象和 GDI 对象。
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.