【问题标题】:Assembly conflicts after NuGet updateNuGet 更新后的程序集冲突
【发布时间】:2019-01-12 08:58:45
【问题描述】:

我有一个 .Net Framework 4.7.1 Web 表单应用程序和 .Net Framework 4.7.1。 WebJob,两者都在 Azure AppService 上运行。

自从通过 Nuget WebJob 包从 2.0.0 更新到 2.2.0 后,出现了一些依赖问题。

第一个在运行时出现:

System.IO.FileLoadException : Could not load file or assembly 'System.Net.Http, Version=4.1.1.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference

编译过程中的第二个显示:

Consider app.config remapping of assembly 用于许多程序集,例如 System.Net.Http、System.Net.Sockets、System.IO.Compression 等。

为了解决这个问题,请参考我添加的源数量和编译器警告

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

这已允许执行 WebJob,但编译器仍会在程序集重新映射时显示警告。

自从我相信 .Net Standard 以来,我看到了更多关于程序集冲突的问题。

你能给我解释一下吗 1. 程序集发生了什么以及为什么我需要打开绑定重定向? 2. 为什么这不能解决第二个问题?

谢谢。

【问题讨论】:

    标签: c# .net nuget assemblies azure-webjobs


    【解决方案1】:
    1. 程序集发生了什么以及为什么我需要打开绑定重定向?

    在构建过程中需要生成它requires assembly binding redirects。在你将它添加到你的 webjobs 之后,它会在你构建时将程序集添加到 bin 文件夹中。

    1. 为什么这不能解决第二个问题?

    看来是VS的问题,你可以在你的webjob References中点击Migrate packages.config to PackageReference来解决。在您的 webjobs 中添加以下 .csproj 并编译。

    <Project Sdk="Microsoft.NET.Sdk">
      <PropertyGroup>
        <OutputType>Exe</OutputType>
        <TargetFramework>net461</TargetFramework>
      </PropertyGroup>
      <ItemGroup>
        <PackageReference Include="Microsoft.Azure.WebJobs" Version="2.2.0" />
      </ItemGroup>
    </Project>
    

    更多详情可以参考这个issue

    【讨论】:

      猜你喜欢
      • 2022-06-13
      • 1970-01-01
      • 2013-12-13
      • 2014-02-25
      • 2013-07-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多