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:
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
精彩评论