I've started learning XNA 4.0 and I'm trying to load and draw a 3D model, converted from 3ds to fbx/x using Blender 2.6 . The program gives no build errors or warnings and I've been able to open the executable few times and it worked fine. After some time I couldn't open the game anymore and it started giving me this error:
AccessViolationException - Attempted to read or write protected memory. This is often an indication that other memory has been corrupted
I sent the project to a friend and he was able to compile & run the game.
Removing mesh.Draw()
part seems to solve this but I need to display the model.
//Later edit: I found out that the error is temporarily, so if it gives the error now, after some time (or reopening visual studio, I don't know yet which one triggers this) I can run the program normally using the same source code and files.
The StackTrace:
System.AccessViolationException was unhandled Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt. Source=Microsoft.Xna.Framework.Graphics
StackTrace: at Microsoft.Xna.Framework.Graphics.GraphicsDevice.Present(tagRECT* pSource, tagRECT* pDest, HWND__* hOverride) at Microsoft.Xna.Framework.Graphics.GraphicsDevice.Present() at Microsoft.Xna.Framework.GraphicsDeviceManager.Microsoft.Xna.Framework.IGraphicsDeviceManager.EndDraw() at Microsoft.Xna.Framework.Game.EndDraw() at Microsoft.Xna.Framework.Game.DrawFrame() at Microsoft.Xna.Framework.Game.Tick() at Microsoft.Xna.Framework.Game.HostIdle(Object sender, EventArgs e) at Microsoft.Xna.Framework.GameHost.OnIdle() at Microsoft.Xna.Framework.WindowsGameHost.RunOneFrame() at Microsoft.Xna.Framework.WindowsGameHost.ApplicationIdle(Object sender, EventArgs e) at System.Windows.Forms.Application.ThreadContext.System.Windows.Forms.UnsafeNativeMethods.IMsoComponent.FDoIdle(Int32 grfidlef) at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.Run(Form mainForm) at Microsoft.Xna.Framework.WindowsGameHost.Run() at Microsoft.Xna.Framework.Game.RunGame(Boolean useBlockingRun) at Microsoft.Xna.Framework.Game.Run() at _3D.Program.Main(String[] args) in C:\Users\username\Desktop\3D\3D\3D\Program.cs:line 15
InnerException:
Thanks in advance and sorry for my bad english.