XbimEssentials icon indicating copy to clipboard operation
XbimEssentials copied to clipboard

Microsoft.Extensions.Logging.Abstractions "could not load file or assembly"

Open PIUM-arc opened this issue 4 years ago • 9 comments

Hello,

I'm facing issues I don't really understand, here is what i did to reproduce the situation. I have created a WindowsFormsControlLibrary (.NET Framework 4.8) project, on my VS 2019 16.8.4. Once my project is created I installed the NLog NuGet packages and wrote a small piece of code to use NLog ( add NLog on my LoggerFactory) At this point, my project runs without any problem, but if I install the Xbim.Common NuGet package, i have this issue : "Could not load file or assembly 'Microsoft.Extensions.Logging.Abstractions', Version = 2.1.0.0

Microsoft.Extensions.Logging.Abstractions Version 5.0.0 package is installed.

I'm not really familiar with this kind of issue, do you have any idea where the problem could come from ? I guess there is dependencies to Microsoft Logging in Xbim.Common but why does this rise an issue like this ?

Thanks

PIUM-arc avatar Feb 04 '21 07:02 PIUM-arc

There is a mismatch between Microsoft.Extensions.Logging.Abstractions versions in your project.

martin1cerny avatar Feb 04 '21 08:02 martin1cerny

It looks like there is a dependency to "Microsoft.Extensions.Logging.Abstractions" version 2.1.0.0 in Xbim.Common , but I have this "Microsoft.Extensions.Logging.Abstractions" package installed in version 5 in my project so why is Xbim.Common still looking for the version 2.1.0.0 ?

PIUM-arc avatar Feb 04 '21 09:02 PIUM-arc

Yes it is. You can try to use binding redirection.

martin1cerny avatar Feb 04 '21 09:02 martin1cerny

I tried but without success. I would like to understand why this issue occurs when I install Xbim.Common in a WindowsFormsControlLibrary project and not in a WindowsFormsApp project. My App.config is the same in both cases.

Thanks

PIUM-arc avatar Feb 04 '21 10:02 PIUM-arc

I'm sorry, but this issue seems to be based on your specific project structure and is external to xbim toolkit.

martin1cerny avatar Feb 04 '21 11:02 martin1cerny

I totally understand, but I'm on empty projects and the issue occurs when I install the Xbim NuGet package, that's why I'm trying to understand why is this package causing this problem. I see in the NuGet package manager that Xbim.Common has dependencies to Microsoft.Extensions.Logging.Abstractions version >=2.1.1 and I have the version 5.0. If there anything specific in this Xbim.Common package that can create this kind of issue ?

PIUM-arc avatar Feb 05 '21 02:02 PIUM-arc

Most likely, Microsoft has broken backwards compatibility between Microsoft.Extensions.Logging.Abstractions, Version = 2.1.0.0 and Version 5.0.0.0

martin1cerny avatar Feb 05 '21 08:02 martin1cerny

Might be worth trying this PR which adds net5 support for Essentials https://github.com/xBimTeam/XbimEssentials/pull/359

We'll get this merged shortly, but in the meantime can you target netcore3?

andyward avatar Feb 05 '21 10:02 andyward

Thank you for your answers, I will have a look at this.

PIUM-arc avatar Feb 05 '21 10:02 PIUM-arc