问题描述
FSDKCam.GetVideoFormatList 是来自外部 .NET dll 的方法.如您所见,它在 try-catch 块中引发异常.
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 { }
截图:
推荐答案
在 .NET 4 中,AccessViolationException
在默认情况下不可捕获.
In .NET 4, AccessViolationException
is not catchable by default.
请参阅 legacyCorruptedStateExceptionsPolicy 配置元素.他们这样做是因为人们在整个代码中都有 try {} catch (Exception) {}
并且捕获 AccessViolationException
(以及其他一些)通常不是一个好主意并继续.
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.
此外,请参阅 http://msdn.microsoft.com/en-us/magazine/dd419661.aspx
这篇关于为什么 try-catch 块无法处理异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!