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

标签 c# azure-functions .net-standard system.data

我正在使用 netstandard2.0 的目标框架在 C# 中创建一个 Azure 函数在 Windows 10 环境中。该函数调用另一个类库中的方法,该方法创建 SqlConnection 的一个实例。当我运行该函数时,出现以下异常:

Microsoft.Azure.WebJobs.Host.FunctionInvocationException : Exception while executing function: Functions.RefreshImages ---> System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation. ---> System.PlatformNotSupportedException : System.Data.SqlClient is not supported on this platform. at System.Data.SqlClient.SqlConnection..ctor(String connectionString)......



显然 SqlConnection 在 Windows 上受支持,所以我认为这里还有其他事情发生。

最佳答案

看起来这与loading a SQL connection via reflection in .NET core有关(您在 netstandard2.0 上运行,但原理应该仍然相同)。

关于c# - 从 C# Azure 函数引用 System.Data.SqlClient 时修复 PlatformNotSupportedException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47718924/

相关文章:

c# - 如何在MVC4项目中调用/引用外部web api项目

java - 如何从用 Java 编写的 Azure Function App 连接到 PostgreSQL?

azure - 如何在隔离进程中创建Azure Function App Service

C#,自定义异常的使用

sitecore - 使用 TextTransform.exe 在 sitecore 中生成 TDS 代码

c# - 翻译asp.net core model Binding messages

c# - .net 的 Selenium 测试覆盖率(C# 和 VB)

c# - 如何在 UWP 中查找 UI 线程

c# - 通过 .NET 自动化在 Word 文档中搜索和替换

azure - 如何在 90 天后使用 sslforfee 自动续订 Azure Key Vault 中的 SSL 证书?