Skip to content

Commit

Permalink
Fix EntryPointNotFoundException in InOutOfProcHelper constructor (dot…
Browse files Browse the repository at this point in the history
  • Loading branch information
0xced authored and Davoud Eshtehari committed Aug 31, 2021
1 parent 08250aa commit ea162b2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions tools/specs/Microsoft.Data.SqlClient.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ When using NuGet 3.x this package requires at least version 3.4.</description>
<dependency id="Microsoft.IdentityModel.Protocols.OpenIdConnect" version="6.8.0" />
<dependency id="Microsoft.IdentityModel.JsonWebTokens" version="6.8.0" />
<dependency id="System.Configuration.ConfigurationManager" version="4.7.0" exclude="Compile" />
<dependency id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" />
</group>
<group targetFramework="netcoreapp2.1">
<dependency id="Microsoft.Data.SqlClient.SNI.runtime" version="3.0.0" exclude="Compile" />
Expand Down

0 comments on commit ea162b2

Please sign in to comment.