Skip to content

System.DllNotFoundException: 'The DLL 'Microsoft.Data.SqlClient.SNI.x86.dll' could not be loaded: The specified module could not be found. (Exception from HRESULT: 0x8007007E)' #3260

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
MojoDK opened this issue Apr 8, 2025 · 1 comment
Assignees
Labels
Needs More Info ℹ️ Issues that have insufficient information to pursue investigations Waiting for Customer ⏳ Issues/PRs waiting for user response/action.
Milestone

Comments

@MojoDK
Copy link

MojoDK commented Apr 8, 2025

Describe the bug

If I create a .Net Framework 4.8 vb.net Winform app and add Microsoft.Data.SqlClient, every thing works fine. If I create a .Net Framework 4.8 vb.net Web (MVC) application and add Microsoft.Data.SqlClient, then I get the error.

Screeencast:
https://app.screencast.com/Awqe1liwal6hi?conversation=jS1SXY0TcTEHZQMhG0tMH1

Exception message:
System.DllNotFoundException: 'The DLL 'Microsoft.Data.SqlClient.SNI.x86.dll' could not be loaded: The specified module could not be found. (Exception from HRESULT: 0x8007007E)'

Stack trace:
System.DllNotFoundException
  HResult=0x80131524
  Message=DLL'en 'Microsoft.Data.SqlClient.SNI.x86.dll' kunne ikke indlæses: Det angivne modul blev ikke fundet. (Undtagelse fra HRESULT: 0x8007007E)
  Source=Microsoft.Data.SqlClient
  StackTrace:
   at Microsoft.Data.SqlClient.SNINativeManagedWrapperX86.UnmanagedIsTokenRestricted(IntPtr token, Boolean& isRestricted)
   at Microsoft.Data.SqlClient.SNINativeMethodWrapper.UnmanagedIsTokenRestricted(IntPtr token, Boolean& isRestricted)
   at Microsoft.Data.Win32NativeMethods.IsTokenRestrictedWrapper(IntPtr token)
   at Microsoft.Data.ProviderBase.DbConnectionPoolIdentity.GetCurrentNative()
   at Microsoft.Data.ProviderBase.DbConnectionPoolGroup.GetConnectionPool(DbConnectionFactory connectionFactory)
   at Microsoft.Data.ProviderBase.DbConnectionFactory.GetConnectionPool(DbConnection owningObject, DbConnectionPoolGroup connectionPoolGroup)
   at Microsoft.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
   at Microsoft.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
   at Microsoft.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
   at Microsoft.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
   at Microsoft.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry, SqlConnectionOverrides overrides)
   at Microsoft.Data.SqlClient.SqlConnection.Open(SqlConnectionOverrides overrides)
   at Microsoft.Data.SqlClient.SqlConnection.Open()
   at WebApplication2.HomeController.Index() in D:\Develop\Projects\_Ic.Core\_Test\Diverse\WebApplication2\WebApplication2\Controllers\HomeController.vb:line 8
   at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
   at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c.<BeginInvokeSynchronousActionMethod>b__9_0(IAsyncResult asyncResult, ActionInvocation innerInvokeState)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass11_0.<InvokeActionMethodFilterAsynchronouslyRecursive>b__0()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass11_2.<InvokeActionMethodFilterAsynchronouslyRecursive>b__2()

To reproduce

  1. Create a VB.Net Framework 4.8 Web MVC application
  2. Add Microsoft.Data.SqlClient Nuget package
  3. Update all packages
  4. In the HomeController Index method, add a new sqlconnection:
    Dim cnn As New SqlConnection("Data Source=MySever;Initial Catalog=MyDb;Persist Security Info=True; Integrated Security=true; application name=abc; Min Pool Size=1; Connection Timeout=30; TrustServerCertificate=True;")
    cnn.Open()
  5. Run the application and the error occurs
Imports Microsoft.Data.SqlClient

Public Class HomeController
    Inherits System.Web.Mvc.Controller

    Function Index() As ActionResult
        Dim cnn As New SqlConnection("Data Source=MyServer;Initial Catalog=MyDb;Persist Security Info=True; Integrated Security=true; application name=abc; Min Pool Size=1; Connection Timeout=30; TrustServerCertificate=True;")
        cnn.Open()
        Return View()
    End Function

    Function About() As ActionResult
        ViewData("Message") = "Your application description page."

        Return View()
    End Function

    Function Contact() As ActionResult
        ViewData("Message") = "Your contact page."

        Return View()
    End Function
End Class

Expected behavior

A new SqlConnection is created and opened.

Further technical details

Microsoft.Data.SqlClient version: 6.0.1
Microsoft.Data.SqlClient.Sni version: 6.0.2
.NET target: .NET Framework 4.8, .NET 6.0
SQL Server version: SQL Server 2022
Operating system: Windows 11 Pro x64

Additional context

@samsharma2700 samsharma2700 self-assigned this Apr 8, 2025
@samsharma2700 samsharma2700 added the Triage Done ✔️ Issues that are triaged by dev team and are in investigation. label Apr 8, 2025
@samsharma2700 samsharma2700 added this to the 6.1-preview1 milestone Apr 8, 2025
@samsharma2700
Copy link
Contributor

samsharma2700 commented Apr 29, 2025

Hey @MojoDK could you also confirm the IDE you used to setup your project and what kind of access you had while doing so. I followed the reproduction steps you shared and was able to connect. Here is a screenshot from debug:

Image Could you kindly update the Nuget packages and confirm if you are facing this on MDS 6.0.2

@samsharma2700 samsharma2700 added Needs More Info ℹ️ Issues that have insufficient information to pursue investigations Waiting for Customer ⏳ Issues/PRs waiting for user response/action. and removed Triage Done ✔️ Issues that are triaged by dev team and are in investigation. labels Apr 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs More Info ℹ️ Issues that have insufficient information to pursue investigations Waiting for Customer ⏳ Issues/PRs waiting for user response/action.
Projects
None yet
Development

No branches or pull requests

3 participants