none
Try catch block not able to catch exception RRS feed

  • Question

  • I am using Windows 7 (x86) and have .net 4.0 istalled.

    I'm working on a WPF application that uses an external library. When executing a method from that library for some inputs(image files) I'm getting AccessViolationException so I'vew put that line in a try catch block. But the application is getting break with that exception only. I'vew used Exception also in ctah block but no use.

    Wednesday, May 8, 2013 5:52 AM

Answers

  • AccessViolationException, StackOverFlowException, OutOfMemoryExceptions are the exceptions which cannot be caught. Because, When any of these exception occur, it means there is a serious bug in your code which could cause potential damage to the system.

    Please mark this post as answer if it solved your problem. Happy Programming!

    • Proposed as answer by chriga Wednesday, May 8, 2013 6:49 PM
    • Marked as answer by Mike FengModerator Tuesday, May 14, 2013 12:26 PM
    Wednesday, May 8, 2013 9:32 AM
  • You should not attempt to catch AccessViolationException, such an exception occurs due to bugs in the native code or due to misuse of the library. You should attempt to find out what the problem is and fix it, not swallow exceptions.
    • Proposed as answer by chriga Wednesday, May 8, 2013 6:49 PM
    • Marked as answer by Mike FengModerator Tuesday, May 14, 2013 12:26 PM
    Wednesday, May 8, 2013 6:18 AM
    Moderator

All replies

  • You should not attempt to catch AccessViolationException, such an exception occurs due to bugs in the native code or due to misuse of the library. You should attempt to find out what the problem is and fix it, not swallow exceptions.
    • Proposed as answer by chriga Wednesday, May 8, 2013 6:49 PM
    • Marked as answer by Mike FengModerator Tuesday, May 14, 2013 12:26 PM
    Wednesday, May 8, 2013 6:18 AM
    Moderator
  • AccessViolationException, StackOverFlowException, OutOfMemoryExceptions are the exceptions which cannot be caught. Because, When any of these exception occur, it means there is a serious bug in your code which could cause potential damage to the system.

    Please mark this post as answer if it solved your problem. Happy Programming!

    • Proposed as answer by chriga Wednesday, May 8, 2013 6:49 PM
    • Marked as answer by Mike FengModerator Tuesday, May 14, 2013 12:26 PM
    Wednesday, May 8, 2013 9:32 AM