You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unable to load DLL 'Microsoft.Data.SqlClient.SNI.x86.dll' #727
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
Reacted by JW, Markus Nißl, Stephen Patten, Jason Baginski, Uwe Keim, Alexandr Bodrov, Dustin Carr, Michael Harris, Juliano Leal Goncalves, Justin Toth and 1 more
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 .
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?
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.
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.
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.
@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.
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?
@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
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.
@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.
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?
@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...).
@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.
Activity
ErikEJ commentedon Sep 16, 2020
Reference the MDS package directly in the .exe projects.
karinazhou commentedon Sep 16, 2020
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 .
jonathan-timothy-mason commentedon Sep 17, 2020
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
ErikEJ commentedon Sep 17, 2020
No, that is not right. This works as expected in most scenarios, so please provide a repro solution.
jonathan-timothy-mason commentedon Sep 24, 2020
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
ErikEJ commentedon Sep 24, 2020
Please provide a .csproj file of a failing "top level" project.
jonathan-timothy-mason commentedon Sep 24, 2020
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
karinazhou commentedon Sep 30, 2020
@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.
jonathan-timothy-mason commentedon Oct 1, 2020
OK, thanks for your help @karinazhou, we'll probably wait until it's been fixed to avoid all the unnecessary references.
cheenamalhotra commentedon Oct 7, 2020
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?
aibrahim2020 commentedon Nov 8, 2020
I'm facing the same issue but with visio Add-in project!! there is no Bin folder when you publish the add-in
gaganpandey1977 commentedon Feb 13, 2021
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.
gaganpandey1977 commentedon Feb 18, 2021
@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.
cheenamalhotra commentedon Feb 18, 2021
If you could upload a repro app, we can take a look and get back to you!
9 remaining items
brain246 commentedon Jan 18, 2023
and the same here. since updating SSMS to preview 4 i cannot connect to any sql instances anymore.solved in my case: see below
reinaldokibel commentedon Jan 23, 2023
same here with SSMS 19 Preview 4 on some servers, not all the servers
asamaras commentedon Jan 24, 2023
Same here, with ssms 19 preview 4, no connection to any server via IP address.
cheenamalhotra commentedon Jan 24, 2023
@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
brain246 commentedon Jan 24, 2023
@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...).
asamaras commentedon Jan 25, 2023
Hi @cheenamalhotra ,
Steps to reproduce:
Update:
After uninstalling, rebooting and re-installing SSMS managed to connect to DB server without issues.
JRahnama commentedon Jan 25, 2023
@asamaras have you tried using FQDN or server name instead of IP address? This could be due to the new feature HostNameInCertificate
asamaras commentedon Jan 25, 2023
@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.
SynapseScribe commentedon Jan 26, 2023
I went to add/remove programs and ran repair on it, which fixed the problem
Ahmad-Hamdeen commentedon Feb 20, 2023
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 ✔)
vladrobilko commentedon Dec 16, 2023
https://stackoverflow.com/questions/45382993/unable-to-load-dll-sni-dll-entity-framework-core/45992774#45992774 - It helped me.
David-Engel commentedon Jun 11, 2024
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