2

FSDKCam.GetVideoFormatList is a method from external .NET dll. As you see the image, it throws an exception in try-catch block.

try
{
    FSDKCam.GetVideoFormatList(ref cameraList[0], out formatList, out count);
    if (count > 0) cmbCameraList.Items.Add(cam);
}
catch { }

Screenshot:

enter image description here

Marco
  • 56,740
  • 14
  • 129
  • 152
Nime Cloud
  • 6,162
  • 14
  • 43
  • 75
  • 1
    Is it actually failing to catch the exception, or is your debugger set to stop when the exception is thrown? – David Sep 09 '11 at 13:02
  • 7
    You probably have set the debugger to break on all exceptions. Next! – leppie Sep 09 '11 at 13:02
  • it could also be visual studio Debugger issue, try to put some logging in the catch block (which you SHOULD do anyway, no reason to catch everything with empty catch block you are only hiding exceptions in this way); then try to run with no debugging and see if your logs are created... – Davide Piras Sep 09 '11 at 13:03
  • Check villecoders' answer in [this question][1], it sounds like a similar issue [1]: http://stackoverflow.com/questions/3469368/how-to-handle-accessviolationexception – curtisk Sep 09 '11 at 13:06
  • An AccessViolationException occurs in unmanaged code, it's not actually in your program. Visual Studio is being helpful and telling you that it happened, but you can disable that option. You should find that this error does not stop your program from running right awa... – MattDavey Sep 09 '11 at 13:07
  • Run the EXE (without debugger): is the error shown to you? If not, you're catching the error because your debugger is set in this way – Marco Sep 09 '11 at 13:11

1 Answers1

9

In .NET 4, AccessViolationException is not catchable by default.

See the legacyCorruptedStateExceptionsPolicy configuration element. They did this because people have try {} catch (Exception) {} throughout their code and it is usually not a good idea to catch AccessViolationException (along with a few others) and continue.

Additionally, see http://msdn.microsoft.com/en-us/magazine/dd419661.aspx

drstevens
  • 2,903
  • 1
  • 21
  • 30