diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlUtil.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlUtil.cs index 868f9eaf9a..27d0df8be2 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlUtil.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlUtil.cs @@ -11,6 +11,7 @@ using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.ExceptionServices; +using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Text; using System.Threading; @@ -358,6 +359,12 @@ sealed internal class InOutOfProcHelper [ResourceConsumption(ResourceScope.Process, ResourceScope.Process)] private InOutOfProcHelper() { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + // SafeNativeMethods.GetModuleHandle calls into kernel32.dll, so return early to avoid + // a System.EntryPointNotFoundException on non-Windows platforms, e.g. Mono. + return; + } // Don't need to close this handle... // SxS: we use this method to check if we are running inside the SQL Server process. This call should be safe in SxS environment. IntPtr handle = SafeNativeMethods.GetModuleHandle(null); diff --git a/tools/specs/Microsoft.Data.SqlClient.nuspec b/tools/specs/Microsoft.Data.SqlClient.nuspec index 8f179ccc9e..c4cc3ae04b 100644 --- a/tools/specs/Microsoft.Data.SqlClient.nuspec +++ b/tools/specs/Microsoft.Data.SqlClient.nuspec @@ -35,6 +35,7 @@ When using NuGet 3.x this package requires at least version 3.4. +