【问题标题】:Azure Functions pre-compiled c# using System.Data.SqlClient missing referenceAzure Functions 使用 System.Data.SqlClient 预编译的 c# 缺少参考
【发布时间】:2023-03-19 05:26:01
【问题描述】:

我创建了一个 Timer Azure 函数,它调用 API 并将 json 响应写入 Azure SQL DB。

我想继续我的项目,所以我在VS2017 中创建了一个Azure Functions App。我移动了我的代码并将#r 脚本引用更改为 sqlclient 的预编译引用。

来自:(脚本调用)

r System.Configuration

r System.Data"

TO: (pre-compiled calls)

using System.Configuration;

using System.Data.SqlClient;

using System.Threading.Tasks;

现在我收到“System.Data.SqlClient”缺少的程序集引用,我不确定如何将它添加到我在 VS 中的 Azure Functions App 项目中。

【问题讨论】:

    标签: azure azure-sql-database azure-functions azure-functions-runtime


    【解决方案1】:

    请转到您的csproj 以检查您所针对的框架。根据您的错误,我猜它看起来像这样:

    <TargetFramework>netstandard2.0</TargetFramework>
    <AzureFunctionsVersion>v2</AzureFunctionsVersion>
    

    这意味着您使用的是 .NET Standard / Functions V2。

    要么将其更改为 .NET Framework / Functions V1:

    <TargetFramework>net461</TargetFramework>
    

    或参考System.Data.SqlClient 的.NET Standard 版本:

    <PackageReference Include="System.Data.SqlClient" Version="4.4.3" />
    

    V1目前是量产版,是C#脚本用的,建议你坚持下去。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-26
      • 1970-01-01
      • 2020-02-24
      • 2019-10-05
      相关资源
      最近更新 更多