From 4dc8e35b685b7ae7a1f33ed1b38dde9f99ff8657 Mon Sep 17 00:00:00 2001 From: Andrew Au Date: Wed, 18 Dec 2019 13:58:31 -0800 Subject: [PATCH] Avoid NullReferenceException in case the code path is run under an incompatible runtime (#711) --- .../DiagnosticsIpc/IpcClient.cs | 4 ++++ 1 file changed, 4 insertions(+) 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 -- 2.34.1