首页 新闻 赞助 找找看

winform图片背景的问题。

0
悬赏园豆:20 [待解决问题]

winform 通过控件属性导入图片(PNG格式),如按钮背景图片、窗体背景、Label控件的背景图片等。,能正常发布、运行。
但是过一段时间后(约3~5小时之间)会报以下错误,然后界面的图片就消失了,程序也一直报错,重新启动程序后又能正常使用一段时间,具体错误如下:

[2020-05-26 13:44:30.161] TextLogger.Error 1
异常文本
【出现时间】:2020/5/26 13:44:30
【异常方法】:get_Flags
【异常窗口】:System.Drawing.dll
【异常类型】:ArgumentException
【异常信息】:Parameter is not valid.
【堆栈调用】: at System.Drawing.Image.get_Flags()
at System.Windows.Forms.ControlPaint.IsImageTransparent(Image backgroundImage)
at System.Windows.Forms.Control.set_BackgroundImageLayout(ImageLayout value)
at IccOilDS.Fmain.InitializeComponent() in E:\IccOilDS\Fmain.Designer.cs:line 268
at IccOilDS.Fmain..ctor() in E:\IccOilDS\Fmain.cs:line 31
at IccOilDS.Frmckdd.btnPrintCKD_Click(Object sender, EventArgs e) in E:\IccOilDS\Frmckdd.cs:line 927
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
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)
【系统版本】:1.0.7450.20051
【总窗体数】:4
【总线程数】:1


[2020-05-26 13:44:35.749] TextLogger.Error 1
异常文本
【出现时间】:2020/5/26 13:44:35
【异常方法】:CheckErrorStatus
【异常窗口】:System.Drawing.dll
【异常类型】:OutOfMemoryException
【异常信息】:Out of memory.
【堆栈调用】: at System.Drawing.Graphics.CheckErrorStatus(Int32 status)
at System.Drawing.Graphics.DrawImage(Image image, Int32 x, Int32 y, Int32 width, Int32 height)
at System.Drawing.Graphics.DrawImage(Image image, Rectangle rect)
at System.Windows.Forms.PictureBox.OnPaint(PaintEventArgs pe)
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.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)
【系统版本】:1.0.7450.20051
【总窗体数】:4
【总线程数】:1


黑色键盘的主页 黑色键盘 | 初学一级 | 园豆:8
提问于:2020-05-27 11:44
< >
分享
所有回答(2)
0
  1. 刪除所有你的业务代码,只留下一个控件,加入背景图片?这样跑跑看。否则你很难证明不是你的其他业务代码或者哪儿的代码造成的。
  2. 如果这样都能出错,你可以去找微软啊。

如果你的应用程序涉及各种媒体类型,WPF是一个特别好的选择。
比如,如果您需要合并视频,文档或图像序列之间的动画过渡,或上述任何组合。
如何你需要创建具有类似Web的导航的桌面应用程序,WPF也很棒。
WPF的优势如下:

  • 能够相对容易地创建非常丰富的UI。
  • 更轻松的动画和特效 天然的强大可扩展性
  • 强大的样式(style)和树形结构
  • 借助Dx可显示高级图形 (Winform 用的是GDI绘图)
爱编程的大叔 | 园豆:30839 (高人七级) | 2020-05-27 11:58
0

大概率是代码有问题,建议发一个可复现问题的demo

会长 | 园豆:12401 (专家六级) | 2020-05-27 13:46
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册