You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

SSIS部署至Azure SQL Server遇System.Net.Http.Formatting组件缺失问题求助

解决SSIS脚本组件中System.Net.Http.Formatting程序集缺失及代码替代方案

一、解决程序集找不到的问题

即使设置了Copy Local=true和本地GAC注册,SQL Server的SSIS运行时仍可能无法定位目标程序集——核心原因是SSIS执行上下文与Visual Studio开发环境相互独立。可尝试以下操作:

  • 将System.Net.Http.Formatting.dll(版本5.2.3.0)复制到SQL Server 2017对应的SSIS组件目录,默认路径为:C:\Program Files\Microsoft SQL Server\140\DTS\Binn
  • 若部署到Azure-SSIS集成运行时,需在Visual Studio中右键程序集文件→属性,设置Copy to Output Directory为Copy always,随后在部署向导中勾选「Include custom assemblies」选项
  • 检查SQL Server服务账户权限,确保其能访问存放该程序集的文件夹

二、修改代码移除对System.Net.Http.Formatting的依赖

假设第114行原代码依赖该程序集实现响应反序列化,可改用以下两种无依赖方案:

方案1:使用System.Text.Json(适配.NET Framework 4.7.2+,SQL Server 2017 SSIS运行时原生支持)

using System.Text.Json;

// 假设response为HttpResponseMessage实例
string responseContent = await response.Content.ReadAsStringAsync();
List<YourClass> classList = JsonSerializer.Deserialize<List<YourClass>>(responseContent, new JsonSerializerOptions
{
    PropertyNameCaseInsensitive = true // 适配TalentLMS返回的驼峰命名字段
});

方案2:使用Newtonsoft.Json(兼容更低版本.NET Framework)

  1. 在脚本组件编辑器中,右键项目→Manage NuGet Packages,搜索安装Newtonsoft.Json包
  2. 替换代码:
using Newtonsoft.Json;

// 假设response为HttpResponseMessage实例
string responseContent = await response.Content.ReadAsStringAsync();
List<YourClass> classList = JsonConvert.DeserializeObject<List<YourClass>>(responseContent);

注:使用Newtonsoft.Json时需确保设置Copy Local=true,保证程序集随包部署,或手动复制到SSIS运行时目录。

内容的提问来源于stack exchange,提问作者AdamC

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.03 12:05:21