我正在使用 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/