问题描述
- c# 读取或写入受保护的内存 异常
-
做的一个地图程序,程序集是其他公司提供的,当往地图里面有大概10000左右的点的时候 ,就会出现如下的错误
异常信息如下
未处理 System.AccessViolationException
Message=尝试读取或写入受保护的内存。这通常指示其他内存已损坏。
Source=Microsoft.DirectX.Direct3D
StackTrace:
在 Microsoft.DirectX.Direct3D.Device.DrawIndexedUserPrimitives(PrimitiveType primitiveType, Int32 minVertexIndex, Int32 numVertexIndices, Int32 primitiveCount, Object indexData, Boolean sixteenBitIndices, Object vertexStreamZeroData)
在 TKsoft.Earth.LineStringRender.Render(DrawArgs e) 位置 E:Object地图demoEarth2.5RenderableNewLayerLineStringRender.cs:行号 242
在 TKsoft.Earth.RenderableList`1.Render(DrawArgs drawArgs) 位置 E:Object地图demoEarth2.5RenderableRenderableListT.cs:行号 107
在 TKsoft.Earth.WorldWindows.Render() 位置 E:Object地图demoEarth2.5WorldWindowsWorldWindows.cs:行号 464
在 TKsoft.Earth.WorldWindows.Application_Idle(Object sender, EventArgs e) 位置 E:Object地图demoEarth2.5WorldWindowsWorldWindows.cs:行号 846
在 System.Windows.Forms.Application.ThreadContext.System.Windows.Forms.UnsafeNativeMethods.IMsoComponent.FDoIdle(Int32 grfidlef)
在 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)
在 System.Windows.Forms.Application.Run(Form mainForm)
在 AreaRadioMonitoringTest.Program.Main() 位置 E:Object海域无线1DevelopLibrary2SourceCodeAreaRadioMonitoringTestProgram.cs:行号 18
在 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:
请问各位大神,出现这个异常主要有什么原因!!
解决方案
不正确地调用api,错误发生在mainform的构造函数中,不在这里。
解决方案二:
当往地图里面有大概10000左右的点的时候 ,就会出现如下的错误
教你一个调试技巧, 在可能出现异常的代码前设置断点,然后运行调试,直接运行。到了发生异常的地方会自动捕捉异常的。到时候你就看到准确的错误了。
解决方案三:
我的异常-VS2012“System.AccessViolationException: 尝试读取或写入受保护的内存。”
时间: 2024-07-29 01:04:41