当前位置:编程学习 > C#/ASP.NET >>

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

render()//渲染函数
{
List<Mesh> Meshs = ToMesh(verts);
            for (int i = 0; i < Meshs.Count; i++)
            {
                if (Meshs[i] != null)
                {
                   Meshs[i].DrawSubset(0);
                }
            }
}

执行一会,在Meshs[i].DrawSubset(0);报错:
未处理 System.AccessViolationException
  Message="尝试读取或写入受保护的内存。这通常指示其他内存已损坏。"
  Source="Microsoft.DirectX.Direct3DX"
  StackTrace:
       在 Microsoft.DirectX.Direct3D.BaseMesh.DrawSubset(Int32 attributeID)
       在 MGis.FormMain.Render()
       在 MGis.Program.Main()
       在 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()
  InnerException: 
--------------------编程问答-------------------- 非托管调用,函数参数定义错误 --------------------编程问答-------------------- 解决了 List<Mesh> Meshs = ToMesh(verts); 一直在内存中new …… --------------------编程问答-------------------- new new 更健康
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,