[CSHARP-2135] Issue with MongoDB.Driver.Core dll version 2.5 Created: 28/Dec/17  Updated: 16/Feb/18  Resolved: 09/Jan/18

Status: Closed
Project: C# Driver
Component/s: API, Connectivity
Affects Version/s: 2.5
Fix Version/s: 2.7.0

Type: Bug Priority: Major - P3
Reporter: Sudha Upadrasta Assignee: Robert Stam
Resolution: Duplicate Votes: 1
Labels: 2.5, Bug, MongoClient
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Visual Studio 2015, 4.5.2 .Net framework, MongoDB 2.5 version, Windows 10


Attachments: PNG File mongoerror.png    
Issue Links:
Duplicate
duplicates CSHARP-2033 Update dependency on System.Runtime.I... Closed

 Description   

Hello Support,

I have trying to make MongoDB work on my system since a week now. I didnt not find any better solution to resolve the issue.Hence I am hoping the issue can be resolved here.,\

We are trying to build a module and use the MongoDB as the directory for the module inputs. Hence we have installed the latest version of Mongo DB dlls from Nuget Package manager, we got 2.5 version of Bson, Core and Driver dlls. Along these, 4.3.0 version of Interop services have been installed.

However when I try to make a connection via code, I get the following error.

Could not load file or assembly 'System.Runtime.InteropServices.RuntimeInformation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) .

Failing at the below highlighted line.

Code snippet:

List<BsonDocument> oList = new List<BsonDocument>();
try
{
IMongoClient client = new MongoClient("mongodb://RedirectUser:brother@ambriig1:27017/Redirect");
IMongoDatabase database = client.GetDatabase("Redirect");
IMongoCollection<BsonDocument> collection = database.GetCollection<BsonDocument>("Urls");
BsonDocument Filter = new BsonDocument("OldURL", path);
oList = collection.Find(Filter).ToList();
return oList;
}

package config looks like:

<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="DnsClient" version="1.0.7" targetFramework="net452" />
<package id="mongocsharpdriver" version="2.5.0" targetFramework="net452" />
<package id="MongoDB.Bson" version="2.5.0" targetFramework="net452" />
<package id="MongoDB.Driver" version="2.5.0" targetFramework="net452" />
<package id="MongoDB.Driver.Core" version="2.5.0" targetFramework="net452" />
<package id="System.Buffers" version="4.3.0" targetFramework="net452" />
<package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="net452" />
</packages>



 Comments   
Comment by Sudha Upadrasta [ 16/Feb/18 ]

Thank you will wait 2.6 Thanks, Sudha

Comment by Robert Stam [ 11/Jan/18 ]

Steps to reproduce would be helpful but not required.

We know that we are depending on an older version of System.Runtime.InteropServices.RuntimeInformation and we fully expect updating our dependency to the current version would take care of this.

This change will be in 2.6, but we don't yet have a release date for 2.6.

Comment by Sudha Upadrasta [ 11/Jan/18 ]

You still wants steps to reproduce? It is really annoying that I am not able to debug on my loca.

I have created a ClassLibrary and target framework is 4.52

When can I expect a fix for this. Please asvise

Comment by Robert Stam [ 02/Jan/18 ]

I did not get this error when creating new test programs in Visual Studio 2017. I was able to target either .NET Framework 4.5 or .NET Core 2.0.

Can you tell me how you created your project and I can attempt to reproduce again?

There is a potential issues with depending on different versions of System.Runtime.InteropServices.RuntimeInformation. The driver depends on version 4.0.0 but DnsClient (which we also depend on) depends on version 4.3.0. We did not realize that there was an indirect dependency on a newer version of System.Runtime.InteropServices.RuntimeInformation.

The most likely fix is to update the driver to depend on version 4.3.0 instead of 4.0.0, that way all direct and indirect dependencies will be on the same version.

Comment by Sudha Upadrasta [ 28/Dec/17 ]

The same logic works fine for my colleague, who has Windows 7. Apart from that both our set up match.

Generated at Wed Feb 07 21:41:42 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.