开发者

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.GetVideoFormatLis开发者_Go百科t(ref cameraList[0], out formatList, out count);
    if (count > 0) cmbCameraList.Items.Add(cam);
}
catch { }

Screenshot:

Why try-catch block cannot handle the exception?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜