Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why try-catch block cannot handle the exception?

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

like image 817
Nime Cloud Avatar asked Apr 10 '26 03:04

Nime Cloud


1 Answers

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

like image 182
drstevens Avatar answered Apr 13 '26 23:04

drstevens