Azure / Azure/azure-functions-core-tools

System.IO.FileLoadException: Could not load file or assembly Microsoft.Extensions.Logging.Abstractions

Open
#3,477 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
1.5k
Forks
498
Avg merge
5d 4h
Merged PRs (30d)
15

Description

Hi All

I have integrated the MongoDB to my existing project which is .NET FrameWork 4.8.

I have created a new class library for mongo and referenced to other libraries

But I'm getting error as below in my development hosting environment as below.

Referenced and main startup class library is having Microsoft.Extensions.Logging.Abstractions with 7.0.1 as Latest, but MongoDB.Driver supports Microsoft.Extensions.Logging.Abstractions >= 2.0.0, i tried by changing versions but no luck

and in log its showing versions which i'm not using and i tried with those too...

ERROR LoggingManager [(null)] - System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Extensions.Logging.Abstractions, Version=3.1.8.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'Microsoft.Extensions.Logging.Abstractions, Version=3.1.8.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' ---> System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Extensions.Logging.Abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'Microsoft.Extensions.Logging.Abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

at MongoDB.Driver.Core.Configuration.ClusterBuilder.CreateClusterFactory()
at MongoDB.Driver.ClusterRegistry.CreateCluster(ClusterKey clusterKey)
at MongoDB.Driver.ClusterRegistry.GetOrCreateCluster(ClusterKey clusterKey)
at MongoDB.Driver.MongoClient..ctor(MongoClientSettings settings)
at MyprojectMongo.DataRepository.GetMongoDbConnection() in F:\myrepositorypath\DataRepository.cs:line 31
at MyprojectMongo.DataRepository.GetMongoCollectionObject[T](String collectionName) in F:\myrepositorypath\DataRepository.cs:line 25
at DataRepository.GetActivityByTimeForActivity(mymodel inputModel, List`1 userIds, MongoQueryConfigOutputModel queryData, LoggedInContext loggedInContext, List`1 validationMessages) in F:\myrepositorypath\DataRepository.cs:line 216

Contributor guide

Open the contributing guide

Research direction

Start with the stack trace from MongoDB.Driver.ClusterBuilder.CreateClusterFactory and the calls in DataRepository.cs at lines 25, 31, and 216. Compare the referenced Microsoft.Extensions.Logging.Abstractions versions in the .NET Framework 4.8 application and hosting environment; done means the MongoClient can be created without the assembly binding exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, mongodb
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.