-
Notifications
You must be signed in to change notification settings - Fork 271
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
Ms.data.sqlclient doesn't work w/ .NetStandard 2.0 class library #204
Comments
ALSO: |
Had a poke at it and it looks like it's using MemoryCache which is in NS2.0+platform extensions. Looking at the project file in netcore it should be generating an NS assembly and I have an assembly locally in my corefx build tree. So it looks like it should be supported and available for SqlClient to use as a dependency. This might be an issue for someone in corefx. |
Okay. Is this going to get fixed or are you going to remove the reference to MS.Data.SqlClient working with NS2.0+ in the md? |
Hi @TheOriginalTom |
ETA? |
@TheOriginalTom It is in our Radar, but not rising above other Active and High Priority list items right now. We'll update you when there's an update. |
AFAIK, Always Encrypted wasn't supposed to work correctly with netstandard2.0. I think this is a bug where an PlatformNotSupportedException should have been thrown instead of Type Initialization failing. cc @David-Engel |
Any idea which apis were missing? |
I don't remember at the top of my head. I will have to dig through the PRs and mail threads. |
I do remember that there were a couple APIs related to crypto. |
So basically there is no way to access AE data from UWP code. (UWP can't ref .NetCore or .NetFramework class libraries.) |
From an email I saved:
|
We are affected by this problem too in the Serilog project: serilog-mssql/serilog-sinks-mssqlserver#208 (comment) Are there any news on this? Can a fix be expected in the future? |
One more observation. From what I have seen in my tests, the problem seems to occur only when using Microsoft.Data.SqlClient from a .NET Standard lib which is used from a .NET Framework app but not when the app is targeting .NET Core. Can anyone confirm if my findings are correct? Thank you very much! |
if you're seeing PlatformNotSupportedExceptions it usually means that you've restored without specifying a runtime. Because the Linux and windows implementations differ the restore has to be done with a valid runtime identifier and while you can develop against the netstandard ref library you can't run against it. |
Close this one because we have the fix in the latest v2.1.0-preview1. |
Describe the bug
A simple ‘SELECT * FROM Table’ on a SQL Server 2017 table that has three Always Encrypted columns in a .NetStandard 2.0 class library returns a SqlException.
Describe the error
If you are seeing an exception, include the full exceptions details (message and stack trace):
Failed to decrypt column 'Name'. The type initializer for 'Microsoft.Data.SqlClient.SqlSymmetricKeyCache' threw an exception. The InnerException is: System.Runtime.Caching is not supported on this platform.
Describe any tests
The following code works in a .NetFramework4.8 class library, and works in .NetCore2.2 class library. It does NOT work in .NetStandard2.0 class library.
Code to reproduce
public static DataTable RunSqlQueryGetDataTable()
{
var sqlquery = "SELECT * FROM ACCOUNT";
DataTable dt = new DataTable();
SqlConnectionStringBuilder sb = new SqlConnectionStringBuilder
{
// local db
IntegratedSecurity = true,
InitialCatalog = "JL",
DataSource = "T\SQLSERVERDEV"
};
using (var sqlConnection = new SqlConnection(string.Concat(sb.ConnectionString, ";Column Encryption Setting=enabled")))
{
using (SqlDataAdapter sda = new SqlDataAdapter(sqlquery, sqlConnection))
{
sda.SelectCommand.CommandType = CommandType.Text;
sda.Fill(dt);
}
}
return dt;
}
Expected behavior
Expect call to return a DataTable object with unencrypted results of the full Select * From statement. This is the result from the .NetFramework and .NetCore calls.
Further technical details
Microsoft.Data.SqlClient version: 19249.1
.NET target: .NetStandard2.0
SQL Server version: SQL Server 2017
Operating system: Windows 10
The text was updated successfully, but these errors were encountered: