Tweaked exception rethrow code.

This commit is contained in:
Eugene Wang
2018-11-23 20:18:13 -05:00
parent 9d7b1154f5
commit c82134e554

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Runtime.ExceptionServices;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@@ -18,9 +19,13 @@ namespace NTwain.Internals
{ {
if (ex != null) if (ex != null)
{ {
#if NET40
typeof(Exception).GetMethod("PrepForRemoting", typeof(Exception).GetMethod("PrepForRemoting",
BindingFlags.NonPublic | BindingFlags.Instance)?.Invoke(ex, new object[0]); BindingFlags.NonPublic | BindingFlags.Instance)?.Invoke(ex, new object[0]);
throw ex; throw ex;
#else
ExceptionDispatchInfo.Capture(ex).Throw();
#endif
} }
} }