diff --git a/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsIpc/IpcClient.cs b/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsIpc/IpcClient.cs index 7d309b670d..1ab6409ea6 100644 --- a/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsIpc/IpcClient.cs +++ b/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsIpc/IpcClient.cs @@ -4,15 +4,13 @@ using System; using System.Diagnostics; -using System.Collections.Generic; using System.IO; using System.IO.Pipes; using System.Linq; +using System.Net; using System.Net.Sockets; using System.Runtime.InteropServices; using System.Security.Principal; -using System.Text; -using System.Text.RegularExpressions; namespace Microsoft.Diagnostics.NETCore.Client { @@ -69,7 +67,7 @@ private static Stream GetTransport(int processId) throw new ServerNotAvailableException($"Process {processId} not running compatible .NET Core runtime."); } string path = Path.Combine(IpcRootPath, ipcPort); - var remoteEP = new UnixDomainSocketEndPoint(path); + var remoteEP = CreateUnixDomainSocketEndPoint(path); var socket = new Socket(AddressFamily.Unix, SocketType.Stream, ProtocolType.Unspecified); socket.Connect(remoteEP); @@ -122,5 +120,17 @@ private static IpcMessage Read(Stream stream) { return IpcMessage.Parse(stream); } + + private static EndPoint CreateUnixDomainSocketEndPoint(string path) + { +#if NETCOREAPP + return new UnixDomainSocketEndPoint(path); +#elif NETSTANDARD2_0 + // UnixDomainSocketEndPoint is not part of .NET Standard 2.0 + var type = typeof(Socket).Assembly.GetType("System.Net.Sockets.UnixDomainSocketEndPoint"); + var ctor = type.GetConstructor(new[] { typeof(string) }); + return (EndPoint)ctor.Invoke(new object[] { path }); +#endif + } } } diff --git a/src/Microsoft.Diagnostics.NETCore.Client/Microsoft.Diagnostics.NETCore.Client.csproj b/src/Microsoft.Diagnostics.NETCore.Client/Microsoft.Diagnostics.NETCore.Client.csproj index dcb33ec0f8..b30d9e8f60 100644 --- a/src/Microsoft.Diagnostics.NETCore.Client/Microsoft.Diagnostics.NETCore.Client.csproj +++ b/src/Microsoft.Diagnostics.NETCore.Client/Microsoft.Diagnostics.NETCore.Client.csproj @@ -1,7 +1,7 @@  Library - netcoreapp2.1 + netstandard2.0;netcoreapp2.1 Microsoft.Diagnostics.NETCore.Client .NET Core Diagnostics Client Library 0.1.0