I use the mongo csharp driver version 1.9.1. But, I have a problems with this dll. The exception is:
"Could not load file or assembly 'MongoDB.Bson, Version=188.8.131.52, Culture=neutral, PublicKeyToken=f686731cfb9cc103' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)":"MongoDB.Bson, Version=184.108.40.206, Culture=neutral, PublicKeyToken=f686731cfb9cc103".
Does anybody have any suggestion ?
Thanks a lot in advance
I was having the same problem, this error occurs due to conflict you may have added more than one reference to MonogoDb in your Solution. Solution: If there are more than one project in your solution remove MongoDb references from all project and then add to only one project that is dependent on all other projects. It worked for me.
To build on Amanullah Tariq's answer; You may have more than one project referencing MongoDb or its drivers, HOWEVER; [solution] make sure that each project make use of the same version. That was what was causing my error. If the versions are not the same, make sure to either upgrade or downgrade the versions to match. I hope this helps any one struggling with this issue in the future.
For me, it was not possible to remove the MongoDB references from all the projects and refer to single project, as it's a utility solution and works on different .net frameworks and .net core versions.
So, I have updated the mongodb driver for the project using nuget and it worked.
Other projects are also working fine. As, MongoDB Drivers gets the reference from the common place.
Before Update of nuget:
After Update of nuget:
If any of the project fails then just update MongoDB.Driver version to the latest.
For .Net Framework:
packages.config file, It will be something like this (sample for 4.7.2 framework):
<package id="MongoDB.Driver" version="2.12.0" targetFramework="net472" />
For .Net Core: check in .csproj file in
<ItemGroup>. Something like this:
<ItemGroup> ...... // other are deleted just to focus on main part <PackageReference Include="MongoDB.Driver" Version="2.12.0" /> </ItemGroup>
User contributions licensed under CC BY-SA 3.0