Skip to content

.NET Standard library not working with .NET Framework #2786

@LNA-DEV

Description

@LNA-DEV

Describe the bug

If you are using the Microsoft.Data.SqlClient NuGet in a .NET Standard project which you are referencing in a .NET Framework project it throws the following exception.

Exception message: System.IO.FileNotFoundException: 'Die Datei oder Assembly "Microsoft.Data.SqlClient, Version=5.0.0.0, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5" oder eine Abhängigkeit davon wurde nicht gefunden. Das System kann die angegebene Datei nicht finden.'
Stack trace:   at StandardLibary.SqlClientWrapper.MakeConnectionToLocalhost() in C:\Users\LNA\source\repos\SqlClient.FrameworkStandard.MRE\StandardLibary\SqlClientWrapper.cs:line 10
   at FrameworkProject.Program.Main(String[] args) in C:\Users\LNA\source\repos\SqlClient.FrameworkStandard.MRE\SqlClient.FrameworkStandard.MRE\Program.cs:line 12

I also noticed that if you take a closer look at the DLLs provided by the NuGet you can see that in the netstandard2.0 folder there only is a .NETCoreApp v8.0 DLL and not the required .NET Standard one.

Workaround

For me the only way to get the NuGet to work is using a older version (5.1.3). But since then there is the wrong version in the .NET Standard folder.

To reproduce

To reproduce this issue you can take a look at this MRE: https://github.com/LNA-DEV/SqlClient.FrameworkStandard.MRE

As you can see .NET works without any issues while .NET Framework throws an exception.

Expected behavior

If there is a .NET Standard version of a NuGet I suspect that it would work on .NET and .NET Framework.

Further technical details

Microsoft.Data.SqlClient version: 5.2.1
.NET target: v4.8
Operating system: Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    Potential RegressionHas not been confirmed as a regression, but it was working properly on a previous version

    Type

    No type

    Projects

    Status

    Needs Investigation

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions