Skip to content
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

MicroSoft.Data.SqlClient is not supported on this platform SNI issue #2729

Open
hietshkumar10 opened this issue Jul 29, 2024 · 7 comments
Open
Labels
⏳ Waiting for Customer Issues/PRs waiting for user response/action.

Comments

@hietshkumar10
Copy link

hietshkumar10 commented Jul 29, 2024

Microsoft.Data.SqlClient is not supported on this platform

Created a class library that is running SQL query using Microsoft.Data.SqlClient.

Used DLL of that class library in console app (Including MIcrosoft.Data.SQLClient.dll)

When running method of class library getting above error

If referring f MIcrosoft.Data.SQLClient.dll from runtimes\win\lib\net6.0 error got changed to (DllNotFoundException: Unable to load DLL 'Microsoft.Data.SqlClient.SNI.dll)

And if trying to add reference of Microsoft.Data.SqlClient.SNI.dll giving Bad IL format issue

Same thing happening if achieving above with code.

(Creating components to existing .net6 Component Manager )

**Exception message:**
DllNotFoundException: Unable to load DLL 'Microsoft.Data.SqlClient.SNI.dll' or one of its dependencies: The specified module could not be found. (0x8007007E)


### Further technical details
**Working ** 
1. If switching AppContext.SetSwitch("Switch.Microsoft.Data.SqlClient.UseManagedNetworkingOnWindows", true); Setting this at stating working fine but this is not recommended to use by Microsoft
3. **If referring MIcrosoft.Data.SQLClient.dll from runtimes\unix\lib\net6.0 it also works fine Don't know why but it doesn't seems good solution and can't use.**
4.  If installing the Microsoft.Data.SqlClient in console app (Can't update existing Component handler)

**using .Net6 VS 2022 Checked** 
@JRahnama JRahnama added the 🆕 Triage Needed For new issues, not triaged yet. label Jul 29, 2024
@JRahnama
Copy link
Contributor

JRahnama commented Jul 29, 2024

@hietshkumar10, try copying the Microsoft.Data.SqlClient.x64.dll or Microsoft.Data.SqlClient.x86.dll, based on the application architecture, from same folder you copied Microsoft.Data.SqlClient.dll from. That should address your issue.

@JRahnama
Copy link
Contributor

**Working **

  1. If switching AppContext.SetSwitch("Switch.Microsoft.Data.SqlClient.UseManagedNetworkingOnWindows", true); Setting this at stating working fine but this is only recommended to use by Microsoft

This will use managed SNI, which means you wont need the native SNI dll.

If referring MIcrosoft.Data.SQLClient.dll from runtimes\unix\lib\net6.0 it also works fine Don't know why but it doesn't seems good solution and can't use.

If you are on windows this is not a good solution. You can refer to runtimes\win dlls and see if that solves the issue for you.

If you handle DLLs and their dependencies, your application may behave differently if you choose the wrong DLL. It is important to select the correct runtime DLL based on your application's setup.

@hietshkumar10
Copy link
Author

hietshkumar10 commented Jul 30, 2024

image

https://learn.microsoft.com/en-us/sql/connect/ado-net/appcontext-switches?view=sql-server-ver16

Can we use this in production(**Going to use on Windows Environment only **)?

@JRahnama

@kf-gonzalez2 kf-gonzalez2 removed the 🆕 Triage Needed For new issues, not triaged yet. label Jul 30, 2024
@JRahnama
Copy link
Contributor

JRahnama commented Aug 1, 2024

@hietshkumar10 there is no issue using ManagedSNI on production, if you are not using MARS (known issue #422 ) everything should work as before.

@JRahnama
Copy link
Contributor

JRahnama commented Aug 1, 2024

To add more, our long term goal is to move away from native libraries and convert everything to managed. A work is in progress to achieve that goal in netcore and after that moving to netfx.

@hietshkumar10
Copy link
Author

Thanks @JRahnama

@cheenamalhotra
Copy link
Member

@hietshkumar10 what client environment are you building/running your application in where you experienced the Native SNI issue? And are you still blocked?

@cheenamalhotra cheenamalhotra added the ⏳ Waiting for Customer Issues/PRs waiting for user response/action. label Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⏳ Waiting for Customer Issues/PRs waiting for user response/action.
Projects
Status: Needs More Info
Development

No branches or pull requests

4 participants