使用Timer自动关闭窗口时异常
环境:VS2005,C#.net CF 2,Windows CE 5。
尝试使用timer自动关闭对话框时出现异常。
运行时错误信息:
“无法显示错误消息,原因是无法找到包含此错误消息的可选资源程序集”
VS2005“调试模式”下可以看到如下输出:
在
System.ArgumentException 中第一次偶然出现的“System.Drawing.dll”类型的异常
未处理的“System.ArgumentException”类型的异常出现在 System.Drawing.dll 中。
其他信息: 值不在预期的范围内。
完整栈信息:
> System.Drawing.dll!Microsoft.AGL.Common.MISC.HandleAr(Microsoft.AGL.Common.PAL_ERROR ar = BadParam) + 0x4b 字节
System.Windows.Forms.dll!System.Windows.Forms.Form._CloseModal() + 0x1a 字节
System.Windows.Forms.dll!System.Windows.Forms.Form.Close() + 0x16 字节
Q0508.exe!Q0508.FormDialoge.timer1_Tick(object sender = {Interval = 3000}, System.EventArgs e = {System.EventArgs}) 行26 + 0x6 字节 C#
System.Windows.Forms.dll!System.Windows.Forms.Timer._WnProc(Microsoft.AGL.Forms.WM wm = WM_TIMER, int wParam = 0, int lParam = 0) + 0x19 字节
System.Windows.Forms.dll!System.Windows.Forms.ApplicationThreadContext._InternalContextMessages(Microsoft.AGL.Forms.WM wm = WM_TIMER, int wParam = 298328, int lParam = 0) + 0x50 字节
System.Windows.Forms.dll!Microsoft.AGL.Forms.EVL.EnterModalDialog(System.IntPtr hwnModal = 1114129)
System.Windows.Forms.dll!System.Windows.Forms.Form.ShowDialog() + 0x60 字节
Q0508.exe!Q0508.Form1.showdialog() 行51 + 0xb 字节 C#
Q0508.exe!Q0508.Form1.timer1_Tick(object sender = {Interval = 1000}, System.EventArgs e = {System.EventArgs}) 行40 + 0xb 字节 C#
System.Windows.Forms.dll!System.Windows.Forms.Timer._WnProc(Microsoft.AGL.Forms.WM wm = WM_TIMER, int wParam = 0, int lParam = 0) + 0x19 字节
System.Windows.Forms.dll!System.Windows.Forms.ApplicationThreadContext._InternalContextMessages(Microsoft.AGL.Forms.WM wm = WM_TIMER, int wParam = 298316, int lParam = 0) + 0x50 字节
System.Windows.Forms.dll!Microsoft.AGL.Forms.EVL.EnterModalDialog(System.IntPtr hwnModal = 1114113)
System.Windows.Forms.dll!System.Windows.Forms.Form.ShowDialog() + 0x60 字节
Q0508.exe!Q0508.Form1.button1_Click(object sender = {Text = "button1"}, System.EventArgs e = {System.EventArgs}) 行34 + 0xb 字节 C#
System.Windows.Forms.dll!System.Windows.Forms.Control.OnClick(System.EventArgs e = {System.EventArgs}) + 0x15 字节
System.Windows.Forms.dll!System.Windows.Forms.Button.OnClick(System.EventArgs e = {System.EventArgs}) + 0x32 字节
System.Windows.Forms.dll!System.Windows.Forms.ButtonBase.WnProc(Microsoft.AGL.Forms.WM wm = WM_BUTTON_NOTIFYCLICKED, int wParam = 0, int lParam = 0) + 0x17 字节
System.Windows.Forms.dll!System.Windows.Forms.Control._InternalWnProc(Microsoft.AGL.Forms.WM wm = WM_BUTTON_NOTIFYCLICKED, int wParam = 0, int lParam = 0) + 0x9 字节
System.Windows.Forms.dll!Microsoft.AGL.Forms.EVL.EnterMainLoop(System.IntPtr hwnMain = 2097165)
System.Windows.Forms.dll!System.Windows.Forms.Application.Run(System.Windows.Forms.Form fm = {Q0508.Form1}) + 0x1a 字节
Q0508.exe!Q0508.Program.Main() 行15 + 0xa 字节 C#
主窗口
C# code
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
g_DisplayAllMessage = new DelDisplayAllMessage(showdialog);
}
private delegate void DelDisplayAllMessage();
DelDisplayAllMessage g_DisplayAllMessage;
FormDialoge d1;
FormDialoge d2;
private void button1_Click(object sender, EventArgs e)
{
timer1.Enabled = true; // 1000ms
if (null == d1)
{
d1 = new FormDialoge();
}