在下面的代码中,我有一个System.UnauthorizedAccessException类异常的catch块。
try
{
var type = message.Form.GetObjTypeOf(typeof(BaseEntity));
MethodInfo updateFormStatusMethod = typeof(IFormService).GetMethod("UpdateFormStatus");
MethodInfo generic = updateFormStatusMethod.MakeGenericMethod(type);
var result = (bool)generic.Invoke(performanceformService, new object[] { message });
// I throw new System.UnauthorizedAccessException() inside 'UpdateFormStatus' method
}
catch (System.UnauthorizedAccessException)
{
// I'm waiting to get 'UnauthorizedAccessException' here
}
catch (System.Exception ex)
{
//But I get it here
}
我正在等待在特定的catch块中获取“ UnauthorizedAccessException”,但在一般的catch块中得到它。
在不同的线程中执行
也许这会有所帮助: