我支持使用dotnet 3.5和ComponentFactory氪v4.4.0.0 winforms应用程序,我最近实现了AppDomain.CurrentDomain。 UnhandledException和Application.ThreadException处理程序通知我发生在客户端上的异常,并发现日志中出现大量错误。这一个是在做我的头在此刻:从窗体窗体“System.ArgumentException:参数无效”Font.GetHeight(图形图形)
System.ArgumentException: Parameter is not valid.
at System.Drawing.Font.GetHeight(Graphics graphics)
at System.Drawing.Font.GetHeight()
at System.Drawing.Font.get_Height()
at System.Windows.Forms.Control.set_Font(Font value)
at System.Windows.Forms.DataGridViewComboBoxEditingControl.ApplyCellStyleToEditingControl(DataGridViewCellStyledataGridViewCellStyle)
at System.Windows.Forms.DataGridView.BeginEditInternal(Boolean selectAll)
at System.Windows.Forms.DataGridView.ProcessKeyEventArgs(Message& m)
at System.Windows.Forms.Control.ProcessKeyMessage(Message& m)
at System.Windows.Forms.Control.WmKeyChar(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.DataGridView.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)
注意堆栈跟踪完全是在Windows代码。还有一个通过我的课的一个通行证:
System.ArgumentException: Parameter is not valid.
at System.Drawing.Font.GetHeight(Graphics graphics)
at System.Drawing.Font.GetHeight()
at System.Drawing.Font.get_Height()
at System.Windows.Forms.Control.set_Font(Font value)
at MyOrg.MyApp.WindowsClient.GuiControls.MaskedTextBoxEditingControl.ApplyCellStyleToEditingControl(DataGridViewCellStyledataGridViewCellStyle)
at System.Windows.Forms.DataGridView.BeginEditInternal(Boolean selectAll)
at System.Windows.Forms.DataGridView.ProcessKeyEventArgs(Message& m)
at System.Windows.Forms.Control.ProcessKeyMessage(Message& m)
at System.Windows.Forms.Control.WmKeyChar(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.DataGridView.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)
下面是该段代码:
public void ApplyCellStyleToEditingControl(DataGridViewCellStyle dataGridViewCellStyle)
{
this.Font = dataGridViewCellStyle.Font;
this.ForeColor = dataGridViewCellStyle.ForeColor;
this.BackColor = dataGridViewCellStyle.BackColor;
this.TextAlign = translateAlignment(dataGridViewCellStyle.Alignment);
}
不告诉我了。
“System.ArgumentException:参数无效”。错误是很可悲的,给我很少去上,但使用dotPeek我看着为Font.Get_Height(图形G)的代码,并发现这是一个GDI +的错误,特别是GetFontHeight:
public float GetHeight(Graphics graphics)
{
if (graphics == null)
{
throw new ArgumentNullException("graphics");
}
else
{
float size;
int fontHeight = SafeNativeMethods.Gdip.GdipGetFontHeight(new HandleRef((object) this, this.NativeFont), new HandleRef((object) graphics, graphics.NativeGraphics), out size);
if (fontHeight != 0)
throw SafeNativeMethods.Gdip.StatusException(fontHeight);
else
return size;
}
}
这是本GDI +方法: http://www.jose.it-berater.org/gdiplus/reference/flatapi/font/gdipgetfontheight.htm
,我的状态错误是无效参数,如记录在这里: http://msdn.microsoft.com/en-us/library/windows/desktop/ms534175(v=vs.85).aspx
遗憾的是没有这种帮助我解决什么错Graphics对象。这是来自该领域用户未处理的异常。我最近发生了内存泄漏,这是由于泄漏的EventHandler和使用了所有可用的GDI句柄引起的,但是我已经修复了这个问题,所以现在我不确定这是内存泄漏,GDI句柄泄漏还是坏的配置某处由用户执行一些不寻常的事情触发。
任何人有什么想法?非常感谢!
如果你尝试'this.Font = new Font(dataGridViewCellStyle.Font);' – Vladimir 2013-03-27 08:12:01
如果callstack没有通过我的代码,这会有什么帮助?我有这样的感觉,其他东西正在腐蚀图形对象,但我不知道是什么... – matao 2013-03-28 02:18:55
我遇到了同样的问题。你在某些方面解决了吗? – 2013-11-12 15:10:24