-
Notifications
You must be signed in to change notification settings - Fork 270
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
Unable to load DLL 'Microsoft.Data.SqlClient.SNI.x86.dll' #645
Comments
I also tried the recommendations in: #292. However, with no luck. Finally I compiled the project referencing the Microsoft.Data.SqlClient and referenced the dll from the bin folder (that had the NSI dlls inside as well) and only then I got it to run in the FSI. But I am still not sure how you can use the SqlClient in a standalone fsx script file. |
Did you try the AppContext switch? |
@ErikEJ I did that, with no luck. When I build targeted at net46, net472,netstandard2.0 and netstandard2.1, the bin folders for the net versions contain all dependency files. The bin folder for netstandard only contains the proj dll?? |
Hi @halcwb, From the repro description, I assume that your application is targeting .net framework. On Windows, the driver depends on another standalone nuget package Microsoft.Data.SqlClient.SNI which contains the native SNI.dll. According to #292 , you need to reference individual dlls manually if you are using F# scripts. If you only have Microsoft.Data.SqlClient.dll, this will not work as expected. Can you also add Microsoft.Data.SqlClient.SNI.x86.dll from your NuGet package cache to your load script and try with that? For .net standard and .net core app on Windows, try to add And please always use dlls from \runtimes instead of \lib for Microsoft.Data.SqlClient.dll such as |
@karinazhou As I previously wrote, I followed all the instructions as mentioned in #292. I suspect that the SNI dll needs to be in the same directory as the SqlClient? It only works by compiling the project using the SqlClient and then referencing from the bin folder like:
|
@halcwb For .net framework application, yes, the SqlClient will search the same directory for the SNI.dll if required during runtime. For .net core application on Windows, this is also true if you don't specify the following AppContext.SetSwitch in your application:
If you have this AppContext.SetSwitch in your .net core application, the SqlClient won't rely on SNI.dll. On Linux / Mac, SNI.dll is not required. |
@karinazhou I tried the AppContext.SetSwitch. That didn't work. Also, when I build the project with only netstandard as framework target, I only get the project dll, not the rest of the dependencies dll's. When I then tried to use the project dll I get:
Update:
Then I can use the Microsoft.Data.Client in a script file and the fsi. Thanks for helping out. |
Closing issue as resolved. |
@cheenamalhotra I don't think this issue should be closed as resolved. The approach above is a workaround, not a solution. |
Reopening issue to validate Native SNI to work with F# on Windows. |
That fixes it. I copied the native SNI files from the Nuget folder directly to bin and all was well. |
I used a different approach:
I can then reference the manually copied dll and use the FSI with VSCode. In VS, somehow a netframework runtime is used. Using the context switch doesn't do a thing as far as I can tell. For example, I can use this code in the FSI: #r @"../bin/publish/Microsoft.Data.SqlClient.dll"
open System
open Microsoft.Data.SqlClient
let builder = SqlConnectionStringBuilder()
builder.UserID <- "halcwb"
builder.ConnectionString NOTE |
@cheenamalhotra Looks like this got auto-closed again. |
Is there a fix (instead of a workaround) for this available? |
Describe the bug
A clear and concise description of what the bug is.
I am trying to use the SqlClient (version 2.0.0) in an F# fsi environment. I can load the lib using the following load script:
However, when I try to use the client than I get the following error:
To reproduce
Trying to use the client by any code causes the issue. It seems that the required NSI lib is not referenced/loaded. When I try to reference the lib manually I get a bad cli header
Expected behavior
That the nsi lib is found.
Further technical details
.NET Core SDK (reflecting any global.json):
Version: 3.1.301
Commit: 7feb845744
Runtime Environment:
OS Name: Windows
OS Version: 6.1.7601
OS Platform: Windows
RID: win7-x64
Base Path: C:\Program Files\dotnet\sdk\3.1.301\
Host (useful for support):
Version: 3.1.5
Commit: 65cd789777
.NET Core SDKs installed:
2.1.701 [C:\Program Files\dotnet\sdk]
2.1.801 [C:\Program Files\dotnet\sdk]
2.2.301 [C:\Program Files\dotnet\sdk]
2.2.401 [C:\Program Files\dotnet\sdk]
3.1.100 [C:\Program Files\dotnet\sdk]
3.1.101 [C:\Program Files\dotnet\sdk]
3.1.301 [C:\Program Files\dotnet\sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.19 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.19 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.19 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.1.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
The text was updated successfully, but these errors were encountered: