0

我的应用程序有一个名为CustomLogger(由我们创建)的 nuget 包。CustomLoggerMicrosoft.ApplicationInsights安装了带有版本的 nuget 包2.12.1

在此处输入图像描述

今天我安装了另一个名为HistoryStats(由我们创建)的 nuget 包,其中也Microsoft.ApplicationInsights安装了 nuget 包,但版本较新2.14.0

在此处输入图像描述

安装第二个 nuget 后,我​​的应用程序失败并出现以下错误

无法加载文件或程序集“Microsoft.ApplicationInsights,Version=2.12.1.36699,Culture=neutral,PublicKeyToken=31bf3856ad364e35”或其依赖项之一。该系统找不到指定的文件

这是我在 .csproj 文件中的参考

<PackageReference Include="CustomLogger" Version="2020.2.19.3" />
<PackageReference Include="HistoryStats" Version="2020.4.27.1" />
<PackageReference Include="Dapper" Version="2.0.30" />
<PackageReference Include="Microsoft.Azure.Storage.Blob" Version="11.1.1" />
<PackageReference Include="Microsoft.Azure.Storage.Common" Version="11.1.1" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.1" />

有没有办法Microsoft.ApplicationInsights为不同的 nuget 包引用不同的版本?

4

1 回答 1

0

对于“运行时”元素下的 app.config 中的 WPF 应用程序,您可以相应地添加程序集重定向。下面的示例,您将需要更改数字以适应。

我没有在其他项目类型上使用这些,但想象这个过程是相似的。

<dependentAssembly>
    <assemblyIdentity name="Microsoft.ApplicationInsights" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-2.12.1.36699" newVersion="2.12.1.36699" />
</dependentAssembly>

对于 Azure Functions ,这个问题可能会有所帮助。

于 2020-07-14T14:12:13.877 回答