Avoid NullReferenceException in case the code path is run under an incompatible runti...
authorAndrew Au <andrewau@microsoft.com>
Wed, 18 Dec 2019 21:58:31 +0000 (13:58 -0800)
committerSung Yoon Whang <suwhang@microsoft.com>
Wed, 18 Dec 2019 21:58:31 +0000 (13:58 -0800)
src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsIpc/IpcClient.cs

index 1ab6409ea6a50025bb46a35dc430bf3690027a60..079699c16afb7ef58da3a857f661dba8f05d81d1 100644 (file)
@@ -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