Skip to content

Unable to load DLL 'Microsoft.Data.SqlClient.SNI.x86.dll' #727

Closed as not planned

Description

@jonathan-timothy-mason

Hi,

I have migrated our .NET 4.7.2 x86 solution to Microsoft.Data.SQLClient v2.0.1 using Nuget.

When running our program in Windows 10 64-bit, the error below occurs:
Unable to load DLL 'Microsoft.Data.SqlClient.SNI.x86.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

If I look at the bin folder of our project that deals with the database, which has a dependency on Microsoft.Data.SQLClient, I find:
Microsoft.Data.SqlClient.dll
Microsoft.Data.SqlClient.SNI.x86.dll
Microsoft.Data.SqlClient.SNI.x64.dll

However, if I look at the bin folder of our executable project, which does not have a dependency on Microsoft.Data.SQLClient, but only on our database project, I only find:

Microsoft.Data.SqlClient.dll

If I copy the missing assemblies into the executable bin folder, the problem is solved.

I assume this is a problem with Nuget. What is the best way to solve this without manually copying the missing dependecnies. We have several exeutables.

Upgrading to Nuget 5 didn't help.

Thanks
Jon

Activity

  1. ErikEJ commented on Sep 16, 2020

    @ErikEJ
    Contributor

    Reference the MDS package directly in the .exe projects.

  2. karinazhou commented on Sep 16, 2020

    @karinazhou
    Member

    Hi @jonathan-timothy-mason , as what @ErikEJ suggested, you need reference the Microsoft.Data.SqlClient nuget package directly in your executable project so the nuget manager is able to copy SNI dlls to the target bin folder. Please feel free to try it and see whether it works.


    And one more thing to check, what type is the .NET framework project you are working on? Is it a WebForms project or just a common .NET Framework project? We have some known issues about WebForms project #446 .

  3. jonathan-timothy-mason commented on Sep 17, 2020

    @jonathan-timothy-mason
    Author

    Thanks for your replies @ErikEJ and @karinazhou. To sum up, anything with a dependency on a project using Microsoft.Data.SQLClient doesn't get Microsoft.Data.SqlClient.SNI.xxx.dll copied to it's bin folder. Is that right?

    Do you think unit test projects that have a dependency on our database project would also need to be made to directly reference Microsoft.Data.SQLClient too?

    Thanks a lot.
    @jonathan-timothy-mason

  4. ErikEJ commented on Sep 17, 2020

    @ErikEJ
    Contributor

    To sum up, anything with a dependency on a project using Microsoft.Data.SQLClient doesn't get Microsoft.Data.SqlClient.SNI.xxx.dll copied to it's bin folder. Is that right?

    No, that is not right. This works as expected in most scenarios, so please provide a repro solution.

  5. added
    Area\Native SNI
    on Sep 18, 2020
  6. jonathan-timothy-mason commented on Sep 24, 2020

    @jonathan-timothy-mason
    Author

    Our projects typically reference our data access project, which itself directly references Microsoft.Data.SQLClient. I've included a document, which lists all our top-level projects, and says which experience the "Unable to load DLL 'Microsoft.Data.SqlClient.SNI.x86.dll'" error.

    Our solution has 66 projects and I don't think it would be possible to simplify it into a form that I can send to you, which would still accurately reproduce the same problem.

    Top-Level Projects and “Unable to load DLL 'Microsoft.Data.SqlClient.SNI.x86.dll'” Error.pdf

  7. ErikEJ commented on Sep 24, 2020

    @ErikEJ
    Contributor

    Please provide a .csproj file of a failing "top level" project.

  8. jonathan-timothy-mason commented on Sep 24, 2020

    @jonathan-timothy-mason
    Author

    Hi @ErikEJ, attached is the project file for our main Windows Forms project that does not reference Microsoft.Data.SQLClient directly, but does reference the other projects MatrixDAL, MatrixBLL, MatrixBLLBase, MatrixBllDalShared, which do directly reference it directly.

    UI - Windows.zip

  9. karinazhou commented on Sep 30, 2020

    @karinazhou
    Member

    @jonathan-timothy-mason I looked at the pdf file you attached and all the failing scenarios, except for the VSTest one, can be fixed by directly adding driver's Nuget reference to the top-level project.

    This is the known issue for native SNI.dll. I think, for now, you may have to directly reference driver nuget in your main project as a workaround.

  10. jonathan-timothy-mason commented on Oct 1, 2020

    @jonathan-timothy-mason
    Author

    OK, thanks for your help @karinazhou, we'll probably wait until it's been fixed to avoid all the unnecessary references.

  11. cheenamalhotra commented on Oct 7, 2020

    @cheenamalhotra
    Member

    Hi @jonathan-timothy-mason

    As I replied here: #446 (comment)
    The same applies to any .NET Framework application, could you verify and confirm the feasibility to import SNI targets?

  12. aibrahim2020 commented on Nov 8, 2020

    @aibrahim2020

    @jonathan-timothy-mason I looked at the pdf file you attached and all the failing scenarios, except for the VSTest one, can be fixed by directly adding driver's Nuget reference to the top-level project.

    This is the known issue for native SNI.dll. I think, for now, you may have to directly reference driver nuget in your main project as a workaround.

    I'm facing the same issue but with visio Add-in project!! there is no Bin folder when you publish the add-in

  13. gaganpandey1977 commented on Feb 13, 2021

    @gaganpandey1977

    I tried all these options nothing work for me. I see when i am compiling or publishing the web Application to a folder i see Microsoft.Data.SqlClient.SNI.x86.dll and Microsoft.Data.SqlClient.SNI.x86.pdb inside Bin folder. However when i publish this to Cloud this file i missing.
    I added these lines to .csproj file too.


  14. gaganpandey1977 commented on Feb 18, 2021

    @gaganpandey1977

    @cheenamalhotra any thoughts why my web app is not copying this dll into Bin folder . I explicitly added reference as mention above in .csproj file too.

  15. cheenamalhotra commented on Feb 18, 2021

    @cheenamalhotra
    Member

    If you could upload a repro app, we can take a look and get back to you!

  16. 9 remaining items

  17. brain246 commented on Jan 18, 2023

    @brain246

    and the same here. since updating SSMS to preview 4 i cannot connect to any sql instances anymore.

    solved in my case: see below

  18. reinaldokibel commented on Jan 23, 2023

    @reinaldokibel

    same here with SSMS 19 Preview 4 on some servers, not all the servers

  19. asamaras commented on Jan 24, 2023

    @asamaras

    Same here, with ssms 19 preview 4, no connection to any server via IP address.

  20. cheenamalhotra commented on Jan 24, 2023

    @cheenamalhotra
    Member

    @swePeso @brain246 @reinaldokibel @asamaras

    Could you please provide more info to help us reproduce the issues you're facing with SSMS? Is that something you also reproduce from a .NET Framework Console app with Microsoft.Data.SqlClient?

    cc @shueybubbles

  21. brain246 commented on Jan 24, 2023

    @brain246

    @cheenamalhotra Sorry, can't be of any help anymore regarding this issues, as it is now solved on my machine (after de-installing and reinstalling it....).

    I might have to add that i had several versions of Azure Data Studio (Insiders), VSCode, Visual Studio (2019, 2022) and two instances of SSMS (18 and 19) installed before (yeah, i know... 😄) . After cleaning that mess up and re-installing SSMS19/Preview4 it worked, but in the end i cannot say what did the trick or caused the issue (but maybe that can be a hint for others here...).

  22. asamaras commented on Jan 25, 2023

    @asamaras

    Hi @cheenamalhotra ,
    Steps to reproduce:

    1. PC with Windows 10/64 bit 19045.2486
    2. Download and install SSMS-Setup-ENU.exe from https://go.microsoft.com/fwlink/?linkid=2219772&clcid=0x409 (version 19.4 preview)
    3. Install the application
    4. Connect to a local DB instance via windows authentication, the connection should be successful
    5. Connect to a server via IP and you get the error message.

    Update:
    After uninstalling, rebooting and re-installing SSMS managed to connect to DB server without issues.

  23. JRahnama commented on Jan 25, 2023

    @JRahnama
    Contributor

    @asamaras have you tried using FQDN or server name instead of IP address? This could be due to the new feature HostNameInCertificate

  24. asamaras commented on Jan 25, 2023

    @asamaras

    @JRahnama That indeed could explain it, the server name is set to a local domain but the terminal is not consulting it, I use host file, so there is a possibility that it could not get the certificate from the server. I use IP to connect.
    Most likely I need to setup an AD domain.

  25. SynapseScribe commented on Jan 26, 2023

    @SynapseScribe

    I went to add/remove programs and ran repair on it, which fixed the problem

  26. Ahmad-Hamdeen commented on Feb 20, 2023

    @Ahmad-Hamdeen

    This method had worked with me 👉 if this file "Microsoft.Data.SqlClient.SNI.x86.dll"
    is not exists in this path:
    "C:\Program Files (x86)\Microsoft SQL Server Management Studio 19\Common7\IDE"
    Steps:
    1.Download the file from this link https://www.mediafire.com/file/z2wjnd8vzg9vdf4/Microsoft.Data.SqlClient.SNI.x86.dll/file
    2.Copy and Past it to "C:\Program Files (x86)\Microsoft SQL Server Management Studio 19\Common7\IDE"
    3.Run the SQL Server Management Studio Management Studio 19 (Worked with me ✔)

  27. David-Engel commented on Jun 11, 2024

    @David-Engel
    Contributor

    Closing this issue as it appears to be external and has no specific fix to be made in MDS. This is also likely a duplicate of #612

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area\Native SNI

    Type

    No type

    Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions