0

My application has a nuget package called CustomLogger(created by us). CustomLogger has Microsoft.ApplicationInsights nuget package installed in it with version 2.12.1

enter image description here

Today I installed another nuget package called HistoryStats(created by us) which also has Microsoft.ApplicationInsights nuget package installed in it but with newer version 2.14.0

enter image description here

After installing the second nuget, my application is failing with below error

Could not load file or assembly 'Microsoft.ApplicationInsights, Version=2.12.1.36699, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified

Here is my reference in .csproj file

<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" />

Is there a way to refer different Microsoft.ApplicationInsights version for different nuget package ?

Pரதீப்
  • 91,748
  • 19
  • 131
  • 172

1 Answers1

0

For a WPF application in the app.config under the "runtime" element you can add an assembly redirect accordingly. Example below, you will need to change the numbers to suit.

I am not used these on other project types, but imagine the process is similar.

<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>

For Azure Functions this question may help.

Ryan Thomas
  • 1,724
  • 2
  • 14
  • 27