Previously we'd just throw the catched exception again
which overwrites its stacktrace, making it less useful
since all you can see is e.g. a NullReferenceException
(re)thrown at MobileAuthenticatedStream:218.
We now capture the original exception information so
the stacktrace is more complete.
using System.Net;
using System.Net.Security;
using System.Globalization;
using System.Net;
using System.Net.Security;
using System.Globalization;
+using System.Runtime.ExceptionServices;
using System.Threading;
using System.Threading.Tasks;
using System.Security.Cryptography.X509Certificates;
using System.Threading;
using System.Threading.Tasks;
using System.Security.Cryptography.X509Certificates;
try {
asyncRequest.StartOperation (ProcessHandshake);
} catch (Exception ex) {
try {
asyncRequest.StartOperation (ProcessHandshake);
} catch (Exception ex) {
- throw SetException (ex);
+ ExceptionDispatchInfo.Capture (SetException (ex)).Throw ();
}
} finally {
if (lazyResult == null || lastException != null) {
}
} finally {
if (lazyResult == null || lastException != null) {
var e = lazyResult.Result as Exception;
if (e != null)
var e = lazyResult.Result as Exception;
if (e != null)
- throw SetException (e);
+ ExceptionDispatchInfo.Capture (SetException (e)).Throw ();
}
internal void ValidateCreateContext (bool serverMode, string targetHost, SslProtocols enabledProtocols, X509Certificate serverCertificate, X509CertificateCollection clientCertificates, bool clientCertRequired)
}
internal void ValidateCreateContext (bool serverMode, string targetHost, SslProtocols enabledProtocols, X509Certificate serverCertificate, X509CertificateCollection clientCertificates, bool clientCertRequired)