runtime: System.Data.SqlClient throws PlatformNotSupportedException on AWS Lambda
When using Sql Data Client or EF in .Net Core 1.0 on AWS Lambda the code errors out indicating that the platform is not supported. Is it true that I can get to Sql Server from node.js on Lambda but not C#? Seems a bit odd. Following is the text of the error:
{ "errorType": "AggregateException", "errorMessage": "One or more errors occurred. (The type initializer for 'System.Data.SqlClient.MetaType' threw an exception.)", "stackTrace": [ "at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)", "at System.Threading.Tasks.Task 1.GetResultCore(Boolean waitCompletionNotification)", "at lambda_method(Closure , Stream , Stream , ContextInfo )" ], "cause": { "errorType": "TypeInitializationException", "errorMessage": "The type initializer for 'System.Data.SqlClient.MetaType' threw an exception.", "stackTrace": [ "at System.Data.SqlClient.MetaType.GetMetaTypeFromSqlDbType(SqlDbType target, Boolean isMultiValued)", "at System.Data.SqlClient.SqlParameter.set_SqlDbType(SqlDbType value)", "at initRestoreDB.Function.<FunctionHandler>d__6.MoveNext()" ], "cause": { "errorType": "TypeInitializationException", "errorMessage": "The type initializer for 'System.Data.Common.ADP' threw an exception.", "stackTrace": [ "at System.Data.SqlClient.MetaType..cctor()" ], "cause": { "errorType": "PlatformNotSupportedException", "errorMessage": "Operation is not supported on this platform.", "stackTrace": [ "at System.Runtime.InteropServices.OSPlatform.get_Windows()", "at System.Data.Common.ADP..cctor()" ] } } } }
The is repeatable for any SQL call from Lambda which runs .Net Core 1.0 on AWS Linux.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 31 (11 by maintainers)
Commits related to this issue
- downgrading System.Data.SqlClient due to https://github.com/dotnet/corefx/issues/16994 — committed to thefringeninja/SQLStreamStore by thefringeninja 7 years ago
- downgrading System.Data.SqlClient due to https://github.com/dotnet/corefx/issues/16994 — committed to SQLStreamStore/SQLStreamStore by thefringeninja 7 years ago
- downgrading System.Data.SqlClient due to https://github.com/dotnet/corefx/issues/16994 — committed to Erwinvandervalk/SqlStreamStore by thefringeninja 7 years ago
I hope this could help, in my situation I was deploying a netcore app v1.0 to AWS Lambda. I also use EF Core for data management. Trying to make a Sql Server connection gave me this exception (System.PlatformNotSupportedException). After downgrade from System.Data.SqlClient from 4.3.0 to 4.1.0 I can confirm it works for me.
Okay, will try that once I get a chance.
It appears there is an issue with “System.Data.SqlClient” version greater than “4.1.0”. Any version after this breaks on OS detection in the AWS Linux version used as the OS for Lambda functions. Rolling back my “Microsoft.EntityFrameworkCore.SqlServer” package to version “1.0.3” allows the code to work. Not sure if this allows the issue to be closed or not as there is clearly still a bug in the newer versions of the “System.Data.SqlClient”.