Avoid dependentAssembly within app.config (.net framework)


I'm looking for a way to avoid the need to add dependentAssembly within the app.config file. The actual related project is a library that should be added to a global process. It's not possible to modify the app.config of the global process (.net Framework).

Example of the issue:

1.When adding nuget package Application Insights to my console app => It would not add a 'dependentAssembly' section within my app.config. The Application insights lib works fine when doing a test as well.

2.When adding the nuget package Serilog & Serilog Application Insights, it adds a new 'dependentAssembly' section within the app.config file. This one works fine as well.

However, when removing the 'dependentAssembly' section that is related to application insights, the following error occurs :

Could not load file or assembly 'Microsoft.ApplicationInsights, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

==> This isn't the only serilog plugin that has this kind of issue. The configuration builder includes also 'dependentAssembly' sections within the app.config.

The appconfig example can be found here :

<?xml version="1.0" encoding="utf-8"?>
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="" newVersion="" />
        <assemblyIdentity name="Microsoft.ApplicationInsights" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="" newVersion="" />

The error msg informs that it's looking for Version= while i'm using version 2.16 of application insights. This can be fixed by installing v2.12.., but i don't want to rely on this as it can be different for every server.

Is there another way to define the version nr?

Thank you in advance!

Kind regards, Kurt

asked on Stack Overflow May 25, 2021 by Kurt Colemonts

0 Answers

Nobody has answered this question yet.

User contributions licensed under CC BY-SA 3.0