   InvalidOperationException when using SpriteBatch after a device reset
  Hi,I'm having problems trying to resolve an error I'm getting after a device reset. I've precied the code relevant code below - it runs fine prior to the device reset. The device reset is triggered when I maximise the window having previously minimised it. I'm running the app windowed in XNA 2.0Code :renderTarget = RenderTarget2D(Device, Width, Height, 1, Device.DisplayMode.Format, Device.PresentationParameters.MultiSampleType, Device.PresentationParameters.MultiSampleQuality);depthBuffer = DepthStencilBuffer(renderTarget.GraphicsDevice, renderTarget.Width, renderTarget.Height, Device.DepthStencilBuffer.Format, renderTarget.MultiSampleType, renderTarget.MultiSampleQuality);Device.SetRenderTarget(0, renderTarget);oldDepthBuffer = Device.DepthStencilBuffer;Device.DepthStencilBuffer = depthBuffer;Device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Microsoft.Xna.Framework.Graphics.Color.Black, 1, 0);spriteBatch.Begin();spriteBatch.DrawString(font, Text, new Vector2(X, Y), Microsoft.Xna.Framework.Graphics.Color.White);spriteBatch.End();On spriteBatch.End(); I receive the following errorSystem.InvalidOperationException occurred  Message="An unexpected error has occurred."  Source="Microsoft.Xna.Framework"  StackTrace:  at Microsoft.Xna.Framework.Graphics.GraphicsDevice.DrawIndexedPrimitives(PrimitiveType primitiveType, Int32 baseVertex, Int32 minVertexIndex, Int32 numVertices, Int32 startIndex, Int32 primitiveCount)  at Microsoft.Xna.Framework.Graphics.SpriteBatch.RenderBatch(Texture2D texture, SpriteVertex[] vertices, Int32 offset, Int32 count)  at Microsoft.Xna.Framework.Graphics.SpriteBatch.Flush()  at Microsoft.Xna.Framework.Graphics.SpriteBatch.End()I also run the following cleanup code after the spriteBatch draw, so this has been run on the last render cycle before the device reset// Reset the deviceDevice.SetRenderTarget(0, null);Device.DepthStencilBuffer = oldDepthBuffer;// Retrieve the source textureTexture texture = renderTarget.GetTexture();renderTarget.Dispose();return texture;Also, following the device reset and prior to running this code I create a new SpriteBatch object and reload the 'font' object via its ContentManager (both of which I thought might be causing the issue but alas no). I've looked through the relevant objects at the error point and none seem to be disposed or have missing content. I don't really know what to try next.I'd be most grateful for any input on causes or suggestions of tools I might be able to use to track the problem down - I thought I might be able to discover something via PIX but it didn't seem feasible as there was so much information and I couldn't see any specific functions related to error diagnosis   
  I'm not sure about the XNA side, but in C++, the ID3DXSprite class has OnLostDevice() and OnResetDevice() functions that need to be called before and after a device reset. If you call OnLostDevice() and then try to render, this crashes (At least it used to, I don't know if this is still the case).Is any of that relevant for XNA?   ;  Thanks Steve - I don't think there's anything like that on the SpriteBatch object. I create a new SpriteBatch immediately following the device reset and I'm not even sure I need to do that - I think the device is virtualised in XNA 2.0 so the SpriteBatch should still be valid.One thing I forgot to mention - if, when the device reset occurs, I comment out the DrawString(... line for a few render cycles (so just have an empty Begin..End loop), break the code and then uncomment it works fine again - weird   