异常报错GDI+ 中发生一般性错误。

用,net4.0写的一套自助收银程序,程序正常运行4小时左右就会出现报错(使用全局捕捉异常捕获),然后程序崩溃退出,实在找不到方向,麻烦帮忙分析一下问题
另外程序会使用大量PictureBox控件,但是加载的Bitmap都写成全局变量了,只会加载Bitmap一次,应该不会说出现资源不够的情况把(猜测不知道对不对)
报错内容:
2022-11-11 22:36:32,716 [1] ERROR SelfPos.Program - 捕获到未处理异常:System.Runtime.InteropServices.ExternalException
异常信息:GDI+ 中发生一般性错误。
异常堆栈: 在 System.Drawing.Graphics.CheckErrorStatus(Int32 status)
在 System.Drawing.Graphics.DrawImage(Image image, Int32 x, Int32 y, Int32 width, Int32 height)
在 System.Drawing.Graphics.DrawImage(Image image, Rectangle rect)
在 System.Windows.Forms.PictureBox.OnPaint(PaintEventArgs pe)
在 System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)
在 System.Windows.Forms.Control.WmPaint(Message& m)
在 System.Windows.Forms.Control.WndProc(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

你是有大量图片绘制吗?会不会资源耗尽了啊

我看到一个实例分享的答案,你看看OK不?
思路:

private static int WIDTH_LIMIT = 30000;

曾经遇见过,我印象的这个错误是可以捕捉到的,你在加载图片的的地方加try catch即可,
这是之前的方式,path里面是大量图片的路径

       pictureBox1.ImageLocation = path;

最终我是写成这种方式了

      pictureBox1.Image=new Bitmap(path);