   animationcontroller crashes
  hi guys, i am using c# direct3d. I have loaded a .X mesh object and when i try to animate it using animation controller.AnimationController ac=rootframe.AnimationController;ac.SetTrackAnimationSet(0, ac.GetAnimationSet(0));ac.SetTrackEnable(0, true); then in my render loop i add advance timeac.AdvanceTime(1);when i run the program (the .X object is a tank).. the animation in track 0 runs successfuly until a certain time and then the program crashes and give me this error (Attempted to read or write protected memory. This is often an indication that other memory is corrupt.) at advancetime function.Please i need help..   
  BUMP!   ;  With this little information it is very hard to help you. first of all you should enable directx debugging (visual studio->tools->options->debugging->directx->use debug version of direct3d), now debug your application and in the console output you should see a couple of warnings and errors, which explain the reason for your error most likely.Getting "Attempted to read or write protected memory" in c# usually means you have called uninitialized data or haven't released some data in the correct order (which can be quite annoying and confusing in c# because most memory handling is done in the background and not at the time you expect it to happen).Maybe try also to call AnimationController.SetTrackPosition(0, 0.0f); and AnimationController.ResetTime(); before calling AdvanceTime. Good luck ..   ;  I dont think it is uninitialized data or released data in the wrong order because it works for a while and then crashes. I didnt find directx in (visual studio->tools->options->debugging->..)I have an observation. The advancetime(...) crashes when i call it the 34th time and doesnt care the value added to time.. for example i tried it advancetime(1); crashes at 34advancetime(0.1); crashes at 3.4really amazing API :)Thnx for trying to help and Please reply ASAP.   ;  BUMP!   ;  BUUUUMP!!! plz respond !   ;  Another BUMP!   ;  Bumping likely won't get you help.  Post all the code (use source blocks please) and then maybe someone can help.  It's likely a bug in a totally unrelated part of your code.   ;  using System;using System.Drawing;using System.Collections;using System.ComponentModel;using System.Windows.Forms;using System.Data;using Microsoft.DirectX;using Microsoft.DirectX.Direct3D;public class CustomFrame : Frame{}public class CustomMeshContainer : MeshContainer{    public string xfilepath;    public Texture[] textures;    public Matrix[] offsetmatrices;    public CustomMeshContainer(Device device,string xFilePath, string name,    MeshData meshData, ExtendedMaterial[] materials,    EffectInstance[] effectInstances, GraphicsStream adjacency,    SkinInformation skinInfo)    {   this.Name = name;   this.MeshData = meshData;   if (meshData.Mesh.VertexFormat == VertexFormats.Normal)   {  meshData.Mesh.ComputeNormals();   }   this.SetMaterials(materials);   this.SetEffectInstances(effectInstances);   this.SetAdjacency(adjacency);   if (skinInfo != null)   {  this.SkinInformation = skinInfo;  int numBones = skinInfo.NumberBones;  offsetmatrices = new Matrix[numBones];  for (int i = 0; i < numBones; i++)  { offsetmatrices = skinInfo.GetBoneOffsetMatrix(i);  }   }   this.xfilepath = xFilePath;   Initialize(device);    }    public void Initialize(Device device)    {   ExtendedMaterial[] ematerials = this.GetMaterials();   int n = ematerials.Length;   textures=new Texture[n];   for (int i = 0; i < n; i++)   {  if (ematerials.TextureFilename == null)  { continue;  }  textures = TextureLoader.FromFile(this.MeshData.Mesh.Device, ematerials.TextureFilename);   }    }}public class CustomAllocation : AllocateHierarchy{    public string xfilepath;    public Device device;    public CustomAllocation(Device pdevice,string xfilepath)    {   this.xfilepath = xfilepath;   device = pdevice;    }    public override Frame CreateFrame(string name)    {   CustomFrame f = new CustomFrame();   return (Frame)f;    }    public override MeshContainer CreateMeshContainer(string name, MeshData meshData, ExtendedMaterial[] materials,EffectInstance[] effectInstances, GraphicsStream adjacency, SkinInformation skinInfo)    {   CustomMeshContainer mc = new CustomMeshContainer(device,xfilepath, name, meshData, materials, effectInstances, adjacency, skinInfo);   return (MeshContainer)mc;    }}public class MYFORM : Form{    public Device device;    public bool quit;    public AnimationRootFrame rootframe;    public AnimationController ac;    public MYFORM()    {   CreateDevice();   rootframe = Mesh.LoadHierarchyFromFile("tank2.x", MeshFlags.Managed, device, new CustomAllocation(device, "tank2.x"), null);   this.FormClosed += new FormClosedEventHandler(MYFORM_FormClosed);   ac = rootframe.AnimationController;   ac = rootframe.AnimationController;   ac.SetTrackAnimationSet(0, ac.GetAnimationSet(0));   ac.ResetTime();    ac.SetTrackEnable(0, true);   ac.SetTrackPosition(0, 0.0f);    }    void MYFORM_FormClosed(object sender, FormClosedEventArgs e)    {   quit = true;    }    public void CreateDevice()    {   this.WindowState = FormWindowState.Maximized;   PresentParameters parameters = new PresentParameters();   parameters.Windowed = true;   parameters.SwapEffect = SwapEffect.Discard;   parameters.EnableAutoDepthStencil = true;   parameters.AutoDepthStencilFormat = DepthFormat.D24X8;   parameters.PresentationInterval = PresentInterval.Default;   device = new Device(0, DeviceType.Hardware, this, CreateFlags.HardwareVertexProcessing, parameters);    }    public void DrawScene()    {   if (device == null)  return;   device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0F, 0);   device.Transform.Projection = Matrix.PerspectiveFovLH((float)Math.PI / 4, this.Width / this.Height, 1f, 1500f);   device.Transform.View = Matrix.LookAtLH(new Vector3(0, 0, 825), new Vector3(0, 0, 0), new Vector3(0, 1, 0));   device.Lights[0].Diffuse = Color.White;   device.Lights[0].Direction = new Vector3(0, 0, -1);   device.Lights[0].Enabled = true;   device.Lights[0].Type = LightType.Directional;   device.RenderState.Lighting = true;   device.RenderState.CullMode = Cull.None;   //Begin the scene    ac.AdvanceTime(1);   device.BeginScene();   Render(rootframe.FrameHierarchy,Matrix.Identity);   //End the scene   device.EndScene();   device.Present();    }    public void Render(Frame frame,Matrix parentmatrix)    {   if (frame.FrameSibling != null)   {  Render(frame.FrameSibling, parentmatrix);   }   Matrix FM = frame.TransformationMatrix * parentmatrix;   if (frame.FrameFirstChild != null)   {  Render(frame.FrameFirstChild, FM);   }   ActualRender(frame, FM);    }    public void ActualRender(Frame frame,Matrix FM)    {   if(frame.MeshContainer==null)   {  return;   }   Texture[] textures = ((CustomMeshContainer)frame.MeshContainer).textures;   ExtendedMaterial[] ematerials = frame.MeshContainer.GetMaterials();   device.Transform.World = FM;   CustomMeshContainer mc=(CustomMeshContainer)frame.MeshContainer;   for (int i = 0; i < textures.Length; i++)   {  if (ematerials.Material3D != null)  { device.Material = ematerials.Material3D;  }  if (textures != null)  { device.SetTexture(0, textures);  }  frame.MeshContainer.MeshData.Mesh.DrawSubset(i);   }    }    public void SetUpBoneMatrices()    {    }}public class MYAPP{    static void Main()    {   MYFORM x;   x = new MYFORM();   x.Show();   while (x.quit == false)   {  x.DrawScene();  Application.DoEvents();  System.Threading.Thread.Sleep(50);   }    }};;  You need to develop the ability to debug your own code.  It would seem that you are chewing up resources some how.  DirectX is not going to do this if all you do is call the AdvanceTime function in a rendering loop.  So, walkthrough your own code to see how you could be doing this.People on this forum can help with specific questions about DirectX interfaces and even routines you write to try to do something.  They cannot debug a program for you.