gpt4 book ai didi

dependency-injection - Azure 函数 V3 无法使用 EF 核心 5.0-rc1 加载文件或程序集 Microsoft.Extensions.DependencyInjection.Abstractions,版本 = 5.0.0.0

转载 作者:行者123 更新时间:2023-12-03 15:40:42 26 4
gpt4 key购买 nike

案子
我们正在使用 .netcore 3.1 创建 azure function v3。使用 EF 核心 5.0-rc1 依赖注入(inject)
1) 依赖注入(inject)

[assembly: FunctionsStartup(typeof(xxxxx.Startup))]
namespace xxxxx
{
public class Startup : FunctionsStartup
{
public override void Configure(IFunctionsHostBuilder builder)
{
var services = builder.Services;
var configBuilder = new ConfigurationBuilder()
.SetBasePath(Environment.CurrentDirectory)
.AddJsonFile("local.settings.json", true, reloadOnChange: true)
.AddEnvironmentVariables() ;
ConfigureServices(services);
ConfigureAppSettings(services, configBuilder.Build());
ConfigureLogging(services, configBuilder.Build());
}
}
}
2) EF 核心 5.0 rc-1
https://devblogs.microsoft.com/dotnet/announcing-entity-framework-core-efcore-5-0-rc1/
错误
无法加载文件或程序集“Microsoft.Extensions.DependencyInjection.Abstractions,Version=5.0.0.0,Culture=neutral,PublicKeyToken=adb9793829ddae60”。该系统找不到指定的文件。
image
套餐
以下是引用的包
image
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AzureFunctionsVersion>v3</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.ServiceBus" Version="4.1.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.0-rc.1.20451.14" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.7" />
<PackageReference Include="Serilog.Extensions.Logging" Version="3.0.1" />
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
故障排除
在 startup.cs(依赖注入(inject))中注释以下行可以解决问题
[assembly: FunctionsStartup(typeof(xxxxx.Startup))]

最佳答案

Microsoft.Azure.Functions.Extensions 取决于 .net 标准 2.0 .
enter image description here
Entity Framework Core 5.0 RC1 不能在 .Net 标准 2.0 平台上运行 , 它需要 .net 标准 2.1 .所以找不到Microsoft.Azure.Functions.Extensions .
enter image description here
更多详情可以引用这篇article .

关于dependency-injection - Azure 函数 V3 无法使用 EF 核心 5.0-rc1 加载文件或程序集 Microsoft.Extensions.DependencyInjection.Abstractions,版本 = 5.0.0.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63972495/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com