简体   繁体   English

从C#Azure函数引用System.Data.SqlClient时修复PlatformNotSupportedException

[英]Fixing PlatformNotSupportedException when referencing System.Data.SqlClient from C# Azure Function

I am creating an Azure Function in C# using a target framework of netstandard2.0 in a Windows 10 environment. 我正在Windows 10环境中使用netstandard2.0的目标框架在C#中创建Azure函数。 The function calls a method that's in another class library and that method creates an instance of SqlConnection. 该函数调用另一个类库中的方法,该方法创建SqlConnection的实例。 When I run the function I get the following exception: 当我运行该函数时,出现以下异常:

Microsoft.Azure.WebJobs.Host.FunctionInvocationException : Exception while executing function: Functions.RefreshImages ---> System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation. Microsoft.Azure.WebJobs.Host.FunctionInvocationException:执行功能时发生异常:Functions.RefreshImages ---> System.Reflection.TargetInvocationException:调用的目标已抛出异常。 ---> System.PlatformNotSupportedException : System.Data.SqlClient is not supported on this platform. ---> System.PlatformNotSupportedException:此平台不支持System.Data.SqlClient。 at System.Data.SqlClient.SqlConnection..ctor(String connectionString)...... 在System.Data.SqlClient.SqlConnection..ctor(String connectionString)......

Obviously SqlConnection is supported on Windows so I assume there's something else going on here. 显然,Windows上支持SqlConnection,所以我认为这里还有其他事情。

看起来这与通过.NET核心中的反射加载SQL连接有关(您正在netstandard2.0上运行,但原理仍应相同)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 来自 System.Data.SqlClient 的数据库连接 C# 问题 - Problem with database connection C# from System.Data.SqlClient Azure 函数 - 此平台不支持 System.Data.SqlClient - Azure Function - System.Data.SqlClient is not supported on this platform 使用 System.Data.SqlClient 使用 Azure C# 时找不到“sni.dll” - “sni.dll” not found while using System.Data.SqlClient using Azure C# 无法使用c#System.Data.SqlClient连接到本地数据库 - Can not connect to local database with c# System.Data.SqlClient 为什么我的C#'System.data.sqlclient'无法正常工作? - Why is my C# 'System.data.sqlclient' not working correctly? 即使使用“使用System.Data.SqlClient;”,C#也无法识别SQLConnection。 - C# not recognizing SQLConnection even when using “using System.Data.SqlClient;” netcore3.1 System.Data.SqlClient 上的 Azure 函数 3.0.1:“System.Data.SqlClient.TdsParser”的类型初始值设定项引发异常 - Azure Function 3.0.1 on netcore3.1 System.Data.SqlClient: The type initializer for 'System.Data.SqlClient.TdsParser' threw an exception C# SQL 使用 Nuget System.Data.SqlClient 查询运行时错误? - C# SQL query run time error using Nuget System.Data.SqlClient? C#类System.Data.SqlClient无法加载文件或程序集 - C# Class System.Data.SqlClient can not load file or assembly 当我使用 System.Data.SqlClient 版本 4.4.3 时,无法加载文件或程序集 System.Data.SqlClient,版本 = 4.2.0.2 - Could not load file or assembly System.Data.SqlClient, Version=4.2.0.2 when I use System.Data.SqlClient Version 4.4.3
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM