Why try-catch block cannot handle the exception?

馋奶兔 提交于 2019-12-24 05:55:01

问题


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:


回答1:


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



来源:https://stackoverflow.com/questions/7361992/why-try-catch-block-cannot-handle-the-exception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!