Remove target invocation exceptions (dotnet/extensions#1413)
- Use BindingFlags.DoNotWrapExceptions to invoke\n\nCommit migrated from 0b1aa473a7
This commit is contained in:
parent
e48ed19cf3
commit
7f5f019101
|
|
@ -403,16 +403,20 @@ namespace Microsoft.Extensions.Internal
|
|||
}
|
||||
}
|
||||
|
||||
#if NETCOREAPP3_0
|
||||
return _constructor.Invoke(BindingFlags.DoNotWrapExceptions, binder: null, parameters: _parameterValues, culture: null);
|
||||
#else
|
||||
try
|
||||
{
|
||||
return _constructor.Invoke(_parameterValues);
|
||||
}
|
||||
catch (TargetInvocationException ex)
|
||||
catch (TargetInvocationException ex) when (ex.InnerException != null)
|
||||
{
|
||||
ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
|
||||
// The above line will always throw, but the compiler requires we throw explicitly.
|
||||
throw;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue