How do you handle exceptions?

I took my free-look camera project to work to show my colleagues and when I tried to run it I get an InvalidCallException in my Program.cs on game.Run();

I don't have a 3D card in my work machine but other projects I've created on it have worked fine so I started a new project and copied the game components across and ran it.\

Now I get the same expection when I call DrawUserPrimitives, can anyone tell me what might be happening

And how are you supposed to handle exceptions either in Game Components (which you might not have built) or in code



Answer this question

How do you handle exceptions?

  • hanozo

    Unfortunately all I can catch is an InvalidCallException with the message "External component has thrown an exception." :S Not really indicative of a compatiblity issue is it

    You can get my project from blog (http://www.mailowl.co.za/Downloads/Simple3D.zip) and check it out for yourself; I'm not really doing anything fancy.


  • Forch

    Andre Odendaal wrote:
    I don't have a 3D card in my work machine ...

    From the FAQ:

    Q: Will the XNA Framework require D3D9 hardware
    A:
    A Direct3D 9.0 card, capable of supporting Shader Model 1.1, is the minimum. The recommended level is a card that supports Shader Model 2.0, since most samples and starter kits will require a Shader Model 2.0-compliant card.

    Andre Odendaal wrote:
    And how are you supposed to handle exceptions either in Game Components (which you might not have built) or in code

    You handle exceptions using a try...catch block. For components you can put the block around the UpdateComponents and DrawComponents lines in your game class.



  • Sweed

    Yip, SpaceWars playing perfectly and I'm using an Intel 82915G/GV/910GL Express


  • scottburr

    Is there any more information on the exception you get

    How you handle exceptions is up to you. You could use a messagebox. Once GUI features are available you could use them.

    For compability messages, ideally you'd check and display a message before calling your game's Run method.

    UT and Q3 are old. Even though you're just displaying a simple grid the technology you're using is more advanced than that used in UT and Q3.



  • morpheus3230

    I don't get an exception. Have you tried creating and running a SpaceWars project on the machine Have you tried updating video drivers What video is shown Display Properties | Advanced | Adapter

  • xwinterx

    OK, I use graphics.GraphicsDevice.GraphicsDeviceCapabilities.PixelShaderVersion and graphics.GraphicsDevice.GraphicsDeviceCapabilities.VertexShaderVersion to check for compatibility on my work machine and I get 2 and 3 respectively, so I should be fine for running my application :S

    A Try...Catch block is all good and well but how can I rely to the user that some has occured that stops them from running my game Must I implement just System.Windows to get a MessageBox or is there another recommended way of gracefully handling exceptions when writing managed games

    And if it comes to having to test for capabilities before executing my game what's the best way of relying to the user that thier system is not compatible

    This seems very odd though that I can play games like Unreal Tournament and Quake 3 on my work machine but I can't have a simple app with a grid and free-look camera


  • How do you handle exceptions?