我想将 Azure Function 应用从 .NET 6 升级到 .NET 8,FunctionApp 版本为 4。
我遵循的步骤是将 Visual Studio 升级到 17.9,然后将目标框架更改为
net8.0
。清洁和构建后,我收到此错误:
System.Private.Corelib: 执行函数时出现异常:: 无法加载文件或程序集 'System.Data.Common, Version=8.0.0.0, Culture=neutral, PublicKeyToken='"。系统找不到指定的文件。
我的项目没有使用
System.Data.Common
。我什至尝试明确安装它,但它不起作用。它在属性中也显示为 .NET 8。
我该如何解决这个问题?
这是
.csproj
文件中使用的库及其版本:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Azure. Identity" Version="1.6.0" />
<PackageReference Include="Azure.Security. KeyVault.Secrets" Version="4.3.0" /> <PackageReference Include="Microsoft.Azure. KeyVault" Version="3.0.5" />
<PackageReference Include="Microsoft.Azure. Services. AppAuthentication" Version="1.6.2" /> <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.1.1" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.3" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
我使用的模型类型是进程内模型,但截至目前 .NET8 仅支持隔离的工作进程模型。 所以我按照本文档中提到的步骤进行操作 将 .NET 应用程序从进程内模型迁移到隔离工作模型
效果很好。