0

我目前正在使用一个 Windows 表单应用程序,该应用程序在单击按钮时会打开一个新窗口。当我关闭第二个窗口时,我间歇性地收到以下异常,这反过来又使我的应用程序崩溃。

应用程序:Manager.exe 框架版本:v4.0.30319 描述:进程因未处理的异常而终止。异常信息:System.AccessViolationException 堆栈:在 System.Drawing.SafeNativeMethods+Gdip.GdipDrawImageRectI(System.Runtime.InteropServices.HandleRef, System.Runtime.InteropServices.HandleRef, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32 , Int32, System.Runtime.InteropServices.HandleRef, DrawImageAbort, System.Runtime.InteropServices.HandleRef) 在 System.Drawing.Graphics.DrawImage(System.Drawing.Image, System.Drawing.Rectangle, Int32, Int32, Int32, Int32, System.Drawing.GraphicsUnit, System.Drawing.Imaging.ImageAttributes, DrawImageAbort, IntPtr) 在 System.Drawing.Graphics.DrawImage (System.Drawing.Image, System.Drawing.Rectangle, Int32, Int32, Int32, Int32, System.
在 System.Windows.Forms.ControlPaint.DrawBackgroundImage(System.Drawing.Graphics,System.Drawing.Image,System.Drawing.Color,System.Windows.Forms.ImageLayout,System.Drawing.Rectangle,System.Drawing.Rectangle,系统.Drawing.Point, System.Windows.Forms.RightToLeft) 在 System.Windows.Forms.Control.PaintBackground(System.Windows.Forms.PaintEventArgs, System.Drawing.Rectangle, System.Drawing.Color, System.Drawing.Point)在 System.Windows.Forms.Control.PaintBackground(System.Windows.Forms.PaintEventArgs, System.Drawing.Rectangle) 在 System.Windows.Forms.Control.OnPaintBackground(System.Windows.Forms.PaintEventArgs) 在 System.Windows.Forms .ScrollableControl.OnPaintBackground(System.Windows.Forms.PaintEventArgs) 在 System.Windows.Forms.Control.PaintWithErrorHandling(System.Windows.Forms.PaintEventArgs,Int16) 在 System.Windows.Forms.Control.WmEraseBkgnd(System.Windows.Forms.Message ByRef) 在 System.Windows.Forms.Control.WndProc(System.Windows.Forms.Message ByRef) 在 System.Windows.Forms.ScrollableControl .WndProc(System.Windows.Forms.Message ByRef) 在 System.Windows.Forms.Control+ControlNativeWindow.OnMessage(System.Windows.Forms.Message ByRef) 在 System.Windows.Forms.Control+ControlNativeWindow.WndProc(System.Windows .Forms.Message ByRef) 在 System.Windows.Forms.NativeWindow.Callback(IntPtr, Int32, IntPtr, IntPtr) 在 System.Windows.Forms.UnsafeNativeMethods.IntBeginPaint(System.Runtime.InteropServices.HandleRef, PAINTSTRUCT ByRef) 在系统。 Windows.Forms.Control.WmPaint(System.Windows.Forms.Message ByRef) 在 System.Windows.Forms.Control.WndProc(System.Windows.Forms.Message ByRef) 在 System.Windows.Forms.ScrollableControl.WndProc(System.Windows.Forms.Message ByRef) 在 System.Windows.Forms.Control+ControlNativeWindow.OnMessage(System.Windows.Forms.Message ByRef) 在 System.Windows。 Forms.Control+ControlNativeWindow.WndProc(System.Windows.Forms.Message ByRef) 在 System.Windows.Forms.NativeWindow.Callback(IntPtr, Int32, IntPtr, IntPtr) 在 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG ByRef)IntPtr) 在 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG ByRef)IntPtr) 在 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG ByRef)
在 System.Windows.Forms.Application+ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr, Int32, Int32) 在 System.Windows.Forms.Application+ThreadContext.RunMessageLoopInner(Int32, System.Windows.Forms. ApplicationContext) 在 System.Windows.Forms.Application+ThreadContext.RunMessageLoop(Int32, System.Windows.Forms.ApplicationContext) 在 System.Windows.Forms.Application.Run(System.Windows.Forms.Form) 在 Manager.Program.Main ()

我通常可以在白天毫无问题地打开和关闭,但是如果我让程序在一夜之间运行并尝试在早上打开第二个窗口,当我尝试关闭窗口时会出现此异常。这个异常现在比我第一次开始运行应用程序时更频繁地抛出。

有没有人看到这个异常或知道如何解决它?我在网上进行了广泛搜索,试图找到答案,但一直找不到适用的答案。

4

0 回答 0