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

Application that targets .NET 4.8 does not support System.Data.SqlClient that targets .NET Standard 2.0 #2840

Open
tdGreat opened this issue Sep 9, 2024 · 1 comment
Labels
👴 System.Data.SqlClient Issues that occur in System.Data.SqlClient only.

Comments

@tdGreat
Copy link

tdGreat commented Sep 9, 2024

I have a dll (say TestLib.dll) that targets .NET Standard 2.0, which uses System.Data.SqlClient dll (this also targets .NET Standard 2.0).

Now I'm using the TestLib.dll in an application (say TestApp) that targets .NET 4.8. Running the application results in an exception

System.Data.SqlClient is not supported on this platform

It is because TestApp was loading the System.Data.SqlClient.dll that targets .NET Standard.

If I give the reference to the the System.Data.SqlClient.dll that targets .NET 4.6.1, it works.

To reproduce the issue:

  1. Create a class library that targets .NET Standard 2.0 (TestLibrary)
  2. In the TestLibrary, reference and use SqlClient (which targets .NET Standard 2.0) latest version (4.8.6) and create a function to query something from the database
  3. Build/publish the TestLibrary
  4. Create a console application (TestApp) with .NET 4.8 as target framework and use that class library
  5. Invoke the function that is querying the database
    Note: make sure TestApp is referencing SqlClient that targets .NET Standard 2.0.

When it tries to create a connection object, the exception occurs.

What is the reason for .NET 4.8 not supporting the SqlClient dll that targets .NET Standard 2.0?

@arellegue
Copy link
Contributor

Have you tried to use Microsoft.Data.SqlClient?

We will look into this and get back to you soon.

@arellegue arellegue added the 🆕 Triage Needed For new issues, not triaged yet. label Sep 10, 2024
@kf-gonzalez2 kf-gonzalez2 added 👴 System.Data.SqlClient Issues that occur in System.Data.SqlClient only. and removed 🆕 Triage Needed For new issues, not triaged yet. labels Sep 10, 2024
@kf-gonzalez2 kf-gonzalez2 moved this from Needs triage to Needs Investigation in SqlClient Triage Board Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
👴 System.Data.SqlClient Issues that occur in System.Data.SqlClient only.
Projects
Status: Needs Investigation
Development

No branches or pull requests

3 participants