Catching exceptions not thrown from Sysem.Exception
-
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! -
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!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 fromDirectXException
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