Whilst browsing the source code for System.ComponentModel.DataAnnotations.CustomValidationAttribute here, I saw the following code (shortened):
try
{
methodInfo.Invoke(null, methodParams);
}
catch (TargetInvocationException ex)
{
if (ex.InnerException != null)
{
throw ex.InnerException
}
throw;
}
Here, the code checks if ex.InnerException
is null. I didn't think that a TargetInvocationException could ever have a null InnerException if it was thrown from reflection invocation.
Is this possible? If so, please provide a scenario where the InnerException can be null.
Aucun commentaire:
Enregistrer un commentaire