[英]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.