winform窗体添加背景图片出现的“System.Drawing.dll”类型的异常

江湖影 2013-12-05 11:03:27
开发环境VS2010,极其简单的winform程序,窗体的BackgroudImage属性添加一张图片,然后启动调试就报错。
在 System.AccessViolationException 中第一次偶然出现的“System.Drawing.dll”类型的异常

其他信息: 尝试读取或写入受保护的内存。这通常指示其他内存已损坏。

异常助手信息:

发生了 System.AccessViolationException
Message=尝试读取或写入受保护的内存。这通常指示其他内存已损坏。
Source=System.Drawing
StackTrace:
在 System.Drawing.SafeNativeMethods.Gdip.GdipFillRectangleI(HandleRef graphics, HandleRef brush, Int32 x, Int32 y, Int32 width, Int32 height)
在 System.Drawing.Graphics.FillRectangle(Brush brush, Int32 x, Int32 y, Int32 width, Int32 height)
在 System.Drawing.Graphics.FillRectangle(Brush brush, Rectangle rect)
在 System.Windows.Forms.ControlPaint.DrawBackgroundImage(Graphics g, Image backgroundImage, Color backColor, ImageLayout backgroundImageLayout, Rectangle bounds, Rectangle clipRect, Point scrollOffset, RightToLeft rightToLeft)
在 System.Windows.Forms.Control.PaintBackground(PaintEventArgs e, Rectangle rectangle, Color backColor, Point scrollOffset)
在 System.Windows.Forms.Control.PaintBackground(PaintEventArgs e, Rectangle rectangle)
在 System.Windows.Forms.Control.OnPaintBackground(PaintEventArgs pevent)
在 System.Windows.Forms.ScrollableControl.OnPaintBackground(PaintEventArgs e)
在 System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)
在 System.Windows.Forms.Control.WmEraseBkgnd(Message& m)
在 System.Windows.Forms.Control.WndProc(Message& m)
在 System.Windows.Forms.ScrollableControl.WndProc(Message& m)
在 System.Windows.Forms.Form.WndProc(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
在 System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
在 System.Windows.Forms.Control.SetVisibleCore(Boolean value)
在 System.Windows.Forms.Form.SetVisibleCore(Boolean value)
在 System.Windows.Forms.Control.set_Visible(Boolean value)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.Run(Form mainForm)
在 自带打印.Program.Main() 位置 E:\dotnet\水晶报表打印\自带打印\Program.cs:行号 18
InnerException:
...全文
771 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
江湖影 2013-12-09
  • 打赏
  • 举报
回复
还没有解决方案呢
小猪八Q 2013-12-06
  • 打赏
  • 举报
回复
引用 1 楼 wpfLove 的回复:
只能说在Program.cs的18行抛出的Exception,需要更详细信息~

InnerException的信息,你抛出错误的地方,找出是什么原因抛出的错误,抛出错误时,查看详细信息,参考信息树中的InnerException找到最里面的Exception信息
江湖影 2013-12-06
  • 打赏
  • 举报
回复
引用 6 楼 machong8183 的回复:
你可以新建一个项目,然后添加背景试试
新建了一个项目,同样的问题
水猿兵团五哥 2013-12-06
  • 打赏
  • 举报
回复
你可以新建一个项目,然后添加背景试试
江湖影 2013-12-06
  • 打赏
  • 举报
回复
引用 3 楼 machong8183 的回复:
貌似用到了水晶报表
本来是准备用水晶报表的,也是报错,后来简化问题,改成一个极其简单的winform窗体添加背景图片的问题,依然报错
江湖影 2013-12-06
  • 打赏
  • 举报
回复
调试时中断在
Application.Run(new Form1());
水猿兵团五哥 2013-12-06
  • 打赏
  • 举报
回复
貌似用到了水晶报表
江湖影 2013-12-06
  • 打赏
  • 举报
回复
引用 1 楼 wpfLove 的回复:
只能说在Program.cs的18行抛出的Exception,需要更详细信息~
我新手,如何获取更详细的信息呢?
小猪八Q 2013-12-06
  • 打赏
  • 举报
回复
只能说在Program.cs的18行抛出的Exception,需要更详细信息~
江湖影 2013-12-06
  • 打赏
  • 举报
回复
引用 8 楼 wpfLove 的回复:
[quote=引用 1 楼 wpfLove 的回复:]
只能说在Program.cs的18行抛出的Exception,需要更详细信息~

InnerException的信息,你抛出错误的地方,找出是什么原因抛出的错误,抛出错误时,查看详细信息,参考信息树中的InnerException找到最里面的Exception信息[/quote]

110,539

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧