   [SOLVED] [SlimDX] Get DirectX screen bitmap VB.NET
  I am having a little trouble getting a screen bitmap of a rendered Direct3D screen.  The below example works fine, however the device (graphDevice) seems to be getting corrupted by the GetBackBuffer command, and I find I need to dispose it and rebuild it again after this command.  Everything seems to continue to work OK until I need to reset the device (screen resizing etc)The device can be reset without problems before the GetBackBuffer, but if it is reset after the GetBackBuffer, the device returns the errorSlimDX.Direct3D9.Direct3D9Exception:D3DERR_INVALIDCALL:Invalid call (-2005530516)Dim tempSurface As Surface = graphDevice.GetBackBuffer(0, 0)Dim bmpFromSurface As System.Drawing.Image = System.Drawing.Bitmap.FromStream(Surface.ToStream(tempSurface, ImageFileFormat.Bmp))[Edited by - Monza on September 30, 2009 6:50:12 AM]
  Oh - I found the issue.  Apparently I need to dispose the surface when I've finished with it.  I wonder how many other things in my code I have forgotten to dispose?Dim tempSurface = graphDevice.GetBackBuffer(0, 0)Dim bmpFromSurface As System.Drawing.Image = system.Drawing.Bitmap.FromStream(Surface.ToStream(tempSurface, ImageFileFormat.Bmp))tempSurface.Dispose()   