Skip to content

Commit 00cbff1

Browse files
authored
Fix EntryPointNotFoundException in InOutOfProcHelper constructor (#1120)
1 parent 98ea349 commit 00cbff1

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlUtil.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using System.Reflection;
1212
using System.Runtime.CompilerServices;
1313
using System.Runtime.ExceptionServices;
14+
using System.Runtime.InteropServices;
1415
using System.Runtime.Versioning;
1516
using System.Text;
1617
using System.Threading;
@@ -358,6 +359,12 @@ sealed internal class InOutOfProcHelper
358359
[ResourceConsumption(ResourceScope.Process, ResourceScope.Process)]
359360
private InOutOfProcHelper()
360361
{
362+
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
363+
{
364+
// SafeNativeMethods.GetModuleHandle calls into kernel32.dll, so return early to avoid
365+
// a System.EntryPointNotFoundException on non-Windows platforms, e.g. Mono.
366+
return;
367+
}
361368
// Don't need to close this handle...
362369
// SxS: we use this method to check if we are running inside the SQL Server process. This call should be safe in SxS environment.
363370
IntPtr handle = SafeNativeMethods.GetModuleHandle(null);

tools/specs/Microsoft.Data.SqlClient.nuspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ When using NuGet 3.x this package requires at least version 3.4.</description>
3535
<dependency id="Microsoft.IdentityModel.Protocols.OpenIdConnect" version="6.8.0" />
3636
<dependency id="Microsoft.IdentityModel.JsonWebTokens" version="6.8.0" />
3737
<dependency id="System.Configuration.ConfigurationManager" version="4.7.0" exclude="Compile" />
38+
<dependency id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" />
3839
</group>
3940
<group targetFramework="netcoreapp2.1">
4041
<dependency id="Microsoft.Data.SqlClient.SNI.runtime" version="3.0.0" exclude="Compile" />

0 commit comments

Comments
 (0)