积极答复者
VB.net 2010 尝试读取或写入受保护的内存。这通常指示其他内存已损坏。

问题
-
请教各位一下,我用vb.net2010开发一套软件,一个主窗体和3个其它窗体 A B C。 当我在主窗体上面点击按钮打开窗体A B都没有问题,打开C的时候就弹出如下错误提示!当我关掉VS 2010开发环境的时候,直接运行EXE文件就正常,请教各位这是什么原因和如何解决呢?万分感谢!非常苦恼的是不知道到底是那句代码处理问题。
未处理 System.AccessViolationException
Message=尝试读取或写入受保护的内存。这通常指示其他内存已损坏。
Source=System.Drawing
StackTrace:
在 System.Drawing.SafeNativeMethods.Gdip.GdipDrawRectangleI(HandleRef graphics, HandleRef pen, Int32 x, Int32 y, Int32 width, Int32 height)
在 System.Drawing.Graphics.DrawRectangle(Pen pen, Int32 x, Int32 y, Int32 width, Int32 height)
在 System.Drawing.Graphics.DrawRectangle(Pen pen, Rectangle rect)
在 System.Windows.Forms.UpDownBase.OnPaint(PaintEventArgs e)
在 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.ScrollableControl.WndProc(Message& m)
在 System.Windows.Forms.UpDownBase.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(IntPtr 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)
在 Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
在 Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
在 Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
在 VCMLensSuoFuJi.My.MyApplication.Main(String[] Args) 位置 17d14f5c-a337-4978-8281-53493378c1071.vb:行号 81
在 System.AppDomain._nExecuteAssembly(RuntimeAssembly 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, Boolean ignoreSyncCtx)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Threading.ThreadHelper.ThreadStart()
InnerException:
Trevan
- 已移动 ThankfulHeartModerator 2013年6月2日 1:54 VB.NET内存写入问题
答案
-
未处理 System.AccessViolationException
Message=尝试读取或写入受保护的内存。这通常指示其他内存已损坏。
Source=System.Drawing
StackTrace:
在 System.Drawing.SafeNativeMethods.Gdip.GdipDrawRectangleI(HandleRef graphics, HandleRef pen, Int32 x, Int32 y, Int32 width, Int32 height)
你好,從你所貼的錯誤信息,應該是 CLR 嘗試用 System.Drawing時,準備讀取或寫入時出錯。這可能是RAM 或 顯咭出問題。
但你也說了直接執行 exe 卻沒事。那可能是 Debugger 有 setting 不對,你可試試
Tools menu ->Options -> Debugging -> General -> Uncheck this option "Suppress JIT optimization on module load"
你也可以參考一下下面的link,也可能有關和有助
大家一齊探討、學習和研究,謝謝!
MCSD, MCAD, MCSE+I, MCDBA, MCDST, MCSA, MCTS, MCITP, MCPD,
MCT, Microsoft Community Star(TW & HK),
Microsoft MVP for VB.NET since 2003
My MSMVP Blog- 已编辑 Ken Lin, MSMVP for .NET (2003-2017), rMVP 2013年6月10日 9:12
- 已标记为答案 Youen ZenModerator 2013年6月17日 7:10
全部回复
-
F5调试模式也无法看出那句话出问题吗?
If you think one reply solves your problem, please mark it as An Answer, if you think someone's reply helps you, please mark it as a Proposed Answer
Help by clicking:
Click here to donate your rice to the poor
Click to Donate
Click to feed Dogs & Cats
Found any spamming-senders? Please report at: Spam Report -
未处理 System.AccessViolationException
Message=尝试读取或写入受保护的内存。这通常指示其他内存已损坏。
Source=System.Drawing
StackTrace:
在 System.Drawing.SafeNativeMethods.Gdip.GdipDrawRectangleI(HandleRef graphics, HandleRef pen, Int32 x, Int32 y, Int32 width, Int32 height)
你好,從你所貼的錯誤信息,應該是 CLR 嘗試用 System.Drawing時,準備讀取或寫入時出錯。這可能是RAM 或 顯咭出問題。
但你也說了直接執行 exe 卻沒事。那可能是 Debugger 有 setting 不對,你可試試
Tools menu ->Options -> Debugging -> General -> Uncheck this option "Suppress JIT optimization on module load"
你也可以參考一下下面的link,也可能有關和有助
大家一齊探討、學習和研究,謝謝!
MCSD, MCAD, MCSE+I, MCDBA, MCDST, MCSA, MCTS, MCITP, MCPD,
MCT, Microsoft Community Star(TW & HK),
Microsoft MVP for VB.NET since 2003
My MSMVP Blog- 已编辑 Ken Lin, MSMVP for .NET (2003-2017), rMVP 2013年6月10日 9:12
- 已标记为答案 Youen ZenModerator 2013年6月17日 7:10