-
Type: Bug
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: 2.7.0
-
Component/s: Build
-
None
-
Environment:Windows 10, Visual Studio 2017 15.8.5, .NET framework 4.7.1
-
(copied to CRM)
I created a simple console app running under .NET 4.7.1, added the MongoDB.Driver nuget package with highest versions dependencies. I end up with a very simple project with the following files:
- Program.cs
using MongoDB.Bson; using MongoDB.Driver; using System; namespace ConsoleApp1 { internal class Program { private const string connectionString = "xxxxxx"; private const string databaseName = "xxxxxx"; private const string collectionName = "test"; private static void Main(string[] args) { var mongoUrl = new MongoUrl(connectionString); var mongoClientSettings = MongoClientSettings.FromUrl(mongoUrl); var mongoClient = new MongoClient(mongoClientSettings); IMongoDatabase database = mongoClient.GetDatabase(databaseName); long count = database.GetCollection<BsonDocument>(collectionName).CountDocuments(FilterDefinition<BsonDocument>.Empty); Console.WriteLine(count); Console.ReadLine(); } } }
* packages.config
<?xml version="1.0" encoding="utf-8"?> <packages> <package id="DnsClient" version="1.2.0" targetFramework="net471" /> <package id="MongoDB.Bson" version="2.7.0" targetFramework="net471" /> <package id="MongoDB.Driver" version="2.7.0" targetFramework="net471" /> <package id="MongoDB.Driver.Core" version="2.7.0" targetFramework="net471" /> <package id="System.Buffers" version="4.5.0" targetFramework="net471" /> <package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="net471" /> </packages>
When I execute this program, I get the following error at runtime:
System.IO.FileLoadException: 'Could not load file or assembly 'System.Runtime.InteropServices.RuntimeInformation' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception de HRESULT : 0x80131040)'
The exact same program works when I target .NET framework 4.7 instead of 4.7.1 (and update the package.config accordingly).
It seems to be related to the fact that .NET 4.7.1 includes the DLL System.Runtime.InteropServices.RuntimeInformation in-box, whereas .NET 4.7 does not. Maybe the Mongo.Driver.Core package should not reference this nuget package when targeting .NET framework 4.7.1.
- depends on
-
CSHARP-2174 Use a single solution and set of project files to multi target .NET Framework and .NET Standard
- Closed
-
CSHARP-2400 Build Nuget packages from .csproj files instead of from .nuspec files
- Closed
- duplicates
-
CSHARP-2033 Update dependency on System.Runtime.InteropServices.RuntimeInformation to 4.3.0
- Closed
- is related to
-
CSHARP-2033 Update dependency on System.Runtime.InteropServices.RuntimeInformation to 4.3.0
- Closed