Azure Function .NET Framework 4.7.2 无法加载 System.Threading.Tasks.Extensions 4.2.0.0

发布于 2025-01-09 20:27:39 字数 1663 浏览 1 评论 0原文

我有一个包含 Azure Function 项目和类库的解决方案。 当我尝试在函数项目中使用类库时,出现错误

Unable to load System.Threading.Tasks.Extensions 4.2.0.0

两个项目都安装了 System.Threading.Tasks.Extensions 4.5.4 NuGet 包。 在这里我发现了一个重定向程序集版本的方法。这是类库项目的 xxx.csproj 文件

<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
  <HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>

这是功能项目的 xxxx.csproj (System.Threading.Tasks.Extensions 4.5.4)

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net472</TargetFramework>
    <AzureFunctionsVersion>v1</AzureFunctionsVersion>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Azure.Messaging.ServiceBus" Version="7.6.0" />
    <PackageReference Include="AzureFunctions.Autofac" Version="2.0.0" />
    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions" Version="2.2.0" />
    <PackageReference Include="Microsoft.Azure.WebJobs.ServiceBus" Version="2.2.0" />
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.1" />
    <PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.4" />
  </ItemGroup>
  ...
</Project>

如何解决功能项目中的问题?

I have a solution containing a Azure Function project and a class library.
When I try to use the class library in a function project I get an error

Unable to load System.Threading.Tasks.Extensions 4.2.0.0

Both projects have the System.Threading.Tasks.Extensions 4.5.4 NuGet package installed.
Here I found a way to redirect assembly versions. Here is xxx.csproj file of class library project

<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
  <HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>

Here is xxxx.csproj of function project (System.Threading.Tasks.Extensions 4.5.4)

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net472</TargetFramework>
    <AzureFunctionsVersion>v1</AzureFunctionsVersion>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Azure.Messaging.ServiceBus" Version="7.6.0" />
    <PackageReference Include="AzureFunctions.Autofac" Version="2.0.0" />
    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions" Version="2.2.0" />
    <PackageReference Include="Microsoft.Azure.WebJobs.ServiceBus" Version="2.2.0" />
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.1" />
    <PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.4" />
  </ItemGroup>
  ...
</Project>

How to fix a problem in a feature project?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

巾帼英雄 2025-01-16 20:27:39
  • 我已尝试通过您的设置重现该问题。
  • 能够构建应用程序,包引用中不会出现任何错误,但未正确加载 System.Threading.Tasks.Extensions

在此处输入图像描述

  • 已替换,
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
  <HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>

  <Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
      <HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
   </Reference> 

在此处输入图像描述

  • I have tried to repro the issue with your settings.
  • Able to build the application without any errors in the package references, but assembly reference is not loaded correctly for System.Threading.Tasks.Extensions

enter image description here

  • Replaced,
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
  <HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>

with

  <Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
      <HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
   </Reference> 

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文