Select to view content in your preferred language

3rd Party Library Conflict with Different Version of the Same Library in an Unrelated Add-in

291
6
06-27-2024 11:04 AM
KarenMeinstein
Occasional Contributor

Our add-in uses Log4Net for logging. We're using an old version and there hasn't been any reason to change that.  We've recently encountered an issue where one of our customers is using an add-in from another company and this add-in also uses Log4Net, but a newer version.  Now when our add-in is activated by clicking the tab, a Log4Net error occurs.  I'm able to reproduce this error by creating a test add-in using the newer Log4Net version.  It seems very strange that a 3rd party library used by another add-in should have any effect on an unrelated add-in using a different version of the same same 3rd party library. Has anyone else encountered something like this? An ideas on how to fix this?  I know we can update the Log4Net version, but that won't necessarily keep this from happening again.

0 Kudos
6 Replies
UmaHarano
Esri Regular Contributor

We are not able to reproduce this issue using the Log4Net NuGet. Are you using different versions of the NuGet or are you referencing the Log4Net assemblies directly?

0 Kudos
KarenMeinstein
Occasional Contributor

We are referencing the assemblies directly. Versions 1.2.10.0 and 2.0.17.0. I can send you the assemblies, if needed.  The issue occurs during the log4net configuration code:

FileAppender fa = new FileAppender();

fa.Threshold = Level.Info;

BasicConfigurator.Configure(fa);

Create 2 different add-ins, each with a button that runs the above code, and have one add-in reference the newer version of log4net and one reference the older version. When you click the button on one of the add-ins and then other, you'll get an error.

0 Kudos
UmaHarano
Esri Regular Contributor

@KarenMeinstein 

In Visual Studio, what is the value for the "Specific Version" property for these assemblies you have referenced?

If you have selected "Yes" then you will receive an error when that specific version is not found.

0 Kudos
KarenMeinstein
Occasional Contributor

The "Specific Version" property for both assemblies was set to nothing (i.e., blank).  I changed both to No, and I still get the error.  

0 Kudos
UmaHarano
Esri Regular Contributor

It seems you have introduced a dependency on a specific version of Log4Net into your addin assembly.  If your addin depends on a specific version of a 3rd party dll, the addin is responsible for deploying its dependencies. You can add the specific dll of log4net into your addin as content and it will be deployed to the addin assembly cache where it can be resolved by the .NET assembly resolver.

The other alternative is to upgrade your addin to use the latest version of Log4Net via the NuGet.

0 Kudos
KarenMeinstein
Occasional Contributor

We're already doing exactly that (deploying the log4net assembly) and have been the whole time. Apparently is ISN'T being correctly resolved by the .NET assembly resolver or this conflict with the other version, which is in the assembly cache for the other vendor's software, wouldn't be occurring.

0 Kudos