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

.NET 8 Azure Function使用System.Text.Json时抛出程序集加载错误

解决.NET 8 Azure Function中System.Text.Json程序集加载错误

针对你遇到的System.Text.Json, Version=8.0.0.0程序集找不到的问题,可尝试以下步骤解决:

  • 确认System.Text.Json包版本
    打开项目的.csproj文件,确保已添加与.NET 8匹配的System.Text.Json包引用(版本为8.x系列):

    <PackageReference Include="System.Text.Json" Version="8.0.0" />
    

    若已有引用,检查版本是否为8.x,避免版本不匹配导致加载失败。

  • 验证Azure Functions运行时配置
    确保项目使用支持.NET 8的Azure Functions v4运行时:

    1. 在host.json中指定.NET 8 runtime版本:
      {
        "version": "2.0",
        "runtime": {
          "applicationRuntime": {
            "runtimeVersion": "8.0"
          }
        }
      }
      
    2. 若用Visual Studio开发,右键项目→属性→Azure Functions,确认"运行时版本"选择为.NET 8(对应v4运行时)。
  • 清理重建项目
    执行命令清理缓存并重新编译,避免旧编译文件干扰:

    dotnet clean
    dotnet build
    

    或在Visual Studio中选择"生成"→"清理解决方案",再执行"重新生成解决方案"。

  • 检查部署包完整性
    若部署到Azure,本地生成发布包后解压,查看bin目录下是否存在System.Text.Json.dll且版本为8.0.0.0。若缺失,需确认发布流程是否包含该依赖。

  • 添加程序集绑定重定向(可选)
    若存在依赖冲突,可在.csproj中添加自动生成绑定重定向的配置:

    <PropertyGroup>
      <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
      <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
    </PropertyGroup>
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.29 19:10:15