dotnet / dotnet/SqlClient

.NET Standard library not working with .NET Framework

Open
#2,786 12 comments 3 reactions 0 assignees View on GitHub
Repro Available :heavy_check_mark:
Dominant language
C#
Stars
989
Forks
340
Avg merge
4d 19h
Merged PRs (30d)
72

Description

### 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:

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.