Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Catching exceptions not thrown from Sysem.Exception

Catching exceptions not thrown from Sysem.Exception

Scheduled Pinned Locked Moved C#
graphicsgame-devtutorialquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    Esmo2000
    wrote on last edited by
    #1

    Hey All... So I was working through a directX tutorial and i came across this: // Try to get the current state try { state = this.keyboard.GetCurrentKeyboardState(); // if fetching the state is successful -> exit loop break; } catch (Microsoft.DirectX.DirectInput.InputException) { // let the application handle Windows messages Application.DoEvents(); // Try to get reacquire the keyboard // and don't care about exceptions try { keyboard.Acquire(); } catch (Microsoft.DirectX.DirectInput.InputLostException) { continue; } catch(Microsoft.DirectX.DirectInput.OtherApplicationHasPriorityException) { continue; } } } However, the compiler says that all exceptions have to be derived from System.Exception. What can I do? Thanks a lot, Jim Did I post well? Rate it! Did I post badly? Rate that too!

    S 1 Reply Last reply
    0
    • E Esmo2000

      Hey All... So I was working through a directX tutorial and i came across this: // Try to get the current state try { state = this.keyboard.GetCurrentKeyboardState(); // if fetching the state is successful -> exit loop break; } catch (Microsoft.DirectX.DirectInput.InputException) { // let the application handle Windows messages Application.DoEvents(); // Try to get reacquire the keyboard // and don't care about exceptions try { keyboard.Acquire(); } catch (Microsoft.DirectX.DirectInput.InputLostException) { continue; } catch(Microsoft.DirectX.DirectInput.OtherApplicationHasPriorityException) { continue; } } } However, the compiler says that all exceptions have to be derived from System.Exception. What can I do? Thanks a lot, Jim Did I post well? Rate it! Did I post badly? Rate that too!

      S Offline
      S Offline
      S Senthil Kumar
      wrote on last edited by
      #2

      All the exceptions you have in the catch blocks do seem to have been derived from Exception. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_m/directx/ref/ns/microsoft.directx.directinput/c/inputexception/inputexception.asp[^] says that Microsoft.DirectX.DirectInput.InputException derives from DirectXException which in turn derives from ApplicationException. ApplicationException is a FCL class that derives from System.Exception. Maybe you're missing something else? Regards Senthil _____________________________ My Blog | My Articles | WinMacro

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups