C# 自定义控件绘图 未处理 System.AccessViolationException异常
来源:互联网 发布:淘宝商城男装裤子 编辑:程序博客网 时间:2024/04/30 05:56
在自定义一个控件,绘图(DrawLine)的时候出现了System.AccessViolationException异常异常,如下
未处理 System.AccessViolationException Message="尝试读取或写入受保护的内存。这通常指示其他内存已损坏。" Source="System.Drawing" StackTrace: 在 System.Drawing.SafeNativeMethods.Gdip.GdipDrawLineI(HandleRef graphics, HandleRef pen, Int32 x1, Int32 y1, Int32 x2, Int32 y2) 在 System.Drawing.Graphics.DrawLine(Pen pen, Int32 x1, Int32 y1, Int32 x2, Int32 y2) 在 SinUI.MultiWaveView.DrawOneWave(Graphics g, Pen pen, Int32 stix, Int32[] values) 位置 D:\MyDoc\WorkDir\VS\同步走行V2\MonitorCtl\MultiWaveView.cs:行号 101 在 SinUI.MultiWaveView.OnPaint(PaintEventArgs e) 位置 D:\MyDoc\WorkDir\VS\同步走行V2\MonitorCtl\MultiWaveView.cs:行号 115 在 System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs) 在 System.Windows.Forms.Control.WmPaint(Message& m) 在 System.Windows.Forms.Control.WndProc(Message& m) 在 System.Windows.Forms.ScrollableControl.WndProc(Message& m) 在 System.Windows.Forms.ContainerControl.WndProc(Message& m) 在 System.Windows.Forms.UserControl.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.UnsafeNativeMethods.DispatchMessageW(MSG& msg) 在 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData) 在 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) 在 MonitorCtl.Program.Main() 位置 D:\MyDoc\WorkDir\VS\同步走行V2\MonitorCtl\Program.cs:行号 17 在 System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) 在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) 在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() 在 System.Threading.ThreadHelper.ThreadStart_Context(Object state) 在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) 在 System.Threading.ThreadHelper.ThreadStart()
搞了半天,后来发现是没有开双缓冲的问题,OnLoad的时候打开控件的DoubleBuffered,或者直接设置其属性为true吧。
DoubleBuffered = true;
0 0
- C# 自定义控件绘图 未处理 System.AccessViolationException异常
- VS2010项目出现“未处理System.AccessViolationException”异常
- 未处理System.AccessViolationException 在 SNINativeMethodWrapper.SNIClose(IntPtr pConn)
- 异常:”未处理System.TypeLoadException“
- C#捕获未处理异常
- c#开发中遇到System.AccessViolationException
- c#开发中遇到System.AccessViolationException
- 未处理System.TypeInitializationException异常处理
- C#之解决 未处理的“System.InvalidOperationException”类型的异常出现在 System.dll中...
- C# 捕获未处理的异常
- 未处理的“System.BadImageFormatException”类型的异常
- c# IOCP.ClientEx2.ReadWrite 加断点遭遇System.AccessViolationException 问题
- c#下出现“”未处理System.BadImageFormatException“错误
- 关于System.AccessViolationException错误
- 自定义CrashHandler捕获全局未处理异常
- C#中的未处理异常的拦截
- C# WinForm捕获未处理的异常
- C# WinForm捕获未处理的异常
- CONCAT函数:合并多个参数
- C++ type deduct summary
- android的消息处理机制(图+源码分析)——Looper,Handler,Message
- 异步复制和同步复制
- 100个 Linux命令
- C# 自定义控件绘图 未处理 System.AccessViolationException异常
- UI基础控件(二)-------- UITextField
- 支撑4.5亿活跃用户的WhatsApp架构概览
- 关于“无状态的HTTP连接提供有状态的连接”
- hive 中的多列进行group by查询方法
- JAVA中堆栈和内存分配原理
- 搜索标签切换 属性 要访问的url
- 面试问题总结
- 【git】 创建一个新分支