From: Andrew Au Date: Wed, 18 Dec 2019 21:58:31 +0000 (-0800) Subject: Avoid NullReferenceException in case the code path is run under an incompatible runti... X-Git-Tag: submit/tizen_5.5/20200504.045052~11^2^2~200 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4dc8e35b685b7ae7a1f33ed1b38dde9f99ff8657;p=platform%2Fcore%2Fdotnet%2Fdiagnostics.git Avoid NullReferenceException in case the code path is run under an incompatible runtime (#711) --- diff --git a/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsIpc/IpcClient.cs b/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsIpc/IpcClient.cs index 1ab6409ea..079699c16 100644 --- a/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsIpc/IpcClient.cs +++ b/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsIpc/IpcClient.cs @@ -128,6 +128,10 @@ namespace Microsoft.Diagnostics.NETCore.Client #elif NETSTANDARD2_0 // UnixDomainSocketEndPoint is not part of .NET Standard 2.0 var type = typeof(Socket).Assembly.GetType("System.Net.Sockets.UnixDomainSocketEndPoint"); + if (type == null) + { + throw new PlatformNotSupportedException("Current process is not running a compatible .NET Core runtime."); + } var ctor = type.GetConstructor(new[] { typeof(string) }); return (EndPoint)ctor.Invoke(new object[] { path }); #endif