【问题标题】:Missing assembly reference error in Azure FunctionAzure 函数中缺少程序集引用错误
【发布时间】:2022-01-03 06:45:33
【问题描述】:

我创建了一个 Azure 功能应用程序,但在调试模式下找不到下面提到的程序集

System.Private.CoreLib: Could not load file or assembly 
'Microsoft.Extensions.Logging.Abstractions, Version=5.0.0.0, Culture=neutral, 
PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.

虽然我引用了它,但在输出文件夹中,当我导航到此特定文件的属性时,它会显示文件版本“5.0.20.51904”

下面是我的项目文件

 <Project Sdk="Microsoft.NET.Sdk">
 <PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<AzureFunctionsVersion>v3</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Scheduler.Core\**" />
<EmbeddedResource Remove="Scheduler.Core\**" />
<None Remove="Scheduler.Core\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="AzureFunctions.Autofac" Version="4.0.1" />
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.0.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="SyncFeed_Scheduler.Core\SyncFeed_Scheduler.Core.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
  <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
  <CopyToOutputDirectory>Always</CopyToOutputDirectory>
  <CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>

【问题讨论】:

    标签: c# .net-core azure-functions


    【解决方案1】:

    由于您使用的是 .NET 6,但为 Microsoft.Extensions.Logging 引用版本 5.0.0.0,因此您的项目版本与添加的依赖项之间可能不匹配。

    我认为这可以通过显式添加对Microsoft.Extensions.Logging.Abstractions 5.0.0.0 版本的依赖项来解决

    通过将您的软件包更新到最新版本。
    例如:Microsoft.Extensions.Logging 有一个可用的 6.0.0.0 版本。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-01
      • 1970-01-01
      • 2019-10-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多