XNA Creators Club Online
Page 1 of 1 (5 items)
Sort Posts: Previous Next

Undocumented InvalidOperationException on GraphicsDevice.Reset

Last post 11/10/2008 11:03 AM by XTatic. 4 replies.
  • 8/12/2008 2:01 PM

    Undocumented InvalidOperationException on GraphicsDevice.Reset

    Hey all,

    I'm getting an unpredictable and untraceable exception when I attempt to resize my game panel in WinForms.  Sometimes it happens after a few seconds of resizing, sometimes it takes as much as half a minute.  It seems to be caused by a high frequency of calling GraphicsDevice.Reset.

    Here's my code:

    private void HandleViewportResize(object sender, EventArgs e)  
    {  
        if (panel.Width == 0 || panel.Height == 0)  
            return;  
     
        redrawTimer.Stop();  
     
        PresentationParameters pp = device.PresentationParameters.Clone();  
        pp.BackBufferHeight = panel.Height;  
        pp.BackBufferWidth = panel.Width;  
     
        device.Reset(pp);  
     
        redrawTimer.Start();  

    Unpredictably [as I slowly resize the panel], the device.Reset(pp) line will throw the following exception:

    ************** Exception Text **************  
    System.InvalidOperationException: An unexpected error has occurred.  
       at Microsoft.Xna.Framework.Graphics.GraphicsDevice.Reset(PresentationParameters presentationParameters, GraphicsAdapter graphicsAdapter)  
       at Microsoft.Xna.Framework.Graphics.GraphicsDevice.Reset(PresentationParameters presentationParameters) 

    This exception tells me nothing and it isn't documented on the MSDN site,

    http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.graphicsdevice.reset.aspx

    I put it in a try-catch block, but once the error occurs, something is permanently broken and it catches there repeatedly until something else crashes within a second.

    Has anyone else seen this sort of behavior before?  Any ideas on how to fix it?

    Thanks in advance.

    Luke

  • 8/12/2008 4:05 PM In reply to

    Re: Undocumented InvalidOperationException on GraphicsDevice.Reset

    Switch to the debug DirectX runtime and see if there is anything useful in the native debug spew.
    XNA Framework Developer - blog - homepage
  • 8/12/2008 8:12 PM In reply to

    Re: Undocumented InvalidOperationException on GraphicsDevice.Reset

    Nice tool.  Thanks!

    Unfortunately, I tried running this several times on each of the five message levels, but got no unique information printed to the log upon exception crash.  Most of the messages were things like "Message Received" and then the message.  Nothing special seemed to print when the exception occured, though.

    So, I'm still unable to get more specific information on what's causing the InvalidOperationException.

    Luke

  • 11/10/2008 8:24 AM In reply to

    Re: Undocumented InvalidOperationException on GraphicsDevice.Reset

    I have this problem too, it is when the presentation parameters have full screen flag set to true. Unfortunately the XNA Framework seems to be swallowing the error code thrown by native, so we can't find out what is wrong.
    X-Tatic
    Game/Engine Developer, C#, XNA, HLSL
  • 11/10/2008 11:03 AM In reply to

    Re: Undocumented InvalidOperationException on GraphicsDevice.Reset

    XTatic:
    I have this problem too, it is when the presentation parameters have full screen flag set to true. Unfortunately the XNA Framework seems to be swallowing the error code thrown by native, so we can't find out what is wrong.


    Managed to get it showing in DebugView, D3D reports invalid display mode, this only happens sometimes, the rest of the time it works just fine..
    X-Tatic
    Game/Engine Developer, C#, XNA, HLSL
Page 1 of 1 (5 items) Previous Next