[CSHARP-1807] Missing dependency on System.Runtime.InteropServices.RuntimeInformation Created: 22/Oct/16  Updated: 21/Aug/17  Resolved: 26/Oct/16

Status: Closed
Project: C# Driver
Component/s: Connectivity
Affects Version/s: 2.4.0-beta1
Fix Version/s: 2.4

Type: Bug Priority: Major - P3
Reporter: Robert Stam Assignee: Robert Stam
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related

 Description   

The Nuget packages for 2.4.0-beta1 are missing a required dependency on the System.Runtime.InteropServices.RuntimeInformation Nuget package.

The symptom is the following exception when attempting to communicate with MongoDB:

An unhandled exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
 
Additional information: 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 system cannot find the file specified.



 Comments   
Comment by Ian Mercer [ 19/Aug/17 ]

I have been unable to get this to work at all under ASP.NET. I have tried both versions of the `System.Runtime.InteropServices.RuntimeInformation` from Nuget and have also tried linking directly to all of the DLLs in that package that could possibly work. I've even tried creating my own `System.Runtime.InteropServices.RuntimeInformation` from source code.

But in MongoDB.DriverCore there seems to be a hard dependency on a specific, signed version of the DLL: https://github.com/mongodb/mongo-csharp-driver/blob/db9e7254075435fca9c4dab78eaca894793d5b78/src/MongoDB.Driver.Core/MongoDB.Driver.Core.csproj#L39

`<Reference Include="System.Runtime.InteropServices.RuntimeInformation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">`

Why is this reference so specific? And how do I get MongoDB 2.4 to work under ASP.NET now?

Update, after much experimentation it seems web.config needs the following to work:

<dependentAssembly>
<assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.InteropServices.RuntimeInformation" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>

Whatever redirects Nuget was putting there were incorrect (a 1 instead of a 2). This maybe isn't a MongoDB issue per se, perhaps in the Microsoft Nuget packages / version stamps??

Comment by David Strickland [ 23/Jul/17 ]

I thought this was resolved, but in some flavors of .net 4.5 it is still an issue. I ended up rolling back to 2.3 to get around it. I tried to add the reference, but still had the issue.

Comment by Mike Zak [ 24/Dec/16 ]

This is still a problem when compiling under mono on linux.

The current available nuget version doesn't support System.Runtime.InteropServices.RuntimeInformation
I'm not even sure it's possible to get System.Runtime.InteropServices.RuntimeInformation to work in mono on linux, since it interops with Windows-specific functionality.

Comment by Githook User [ 26/Oct/16 ]

Author:

{u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}

Message: CSHARP-1807: Added missing dependency.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/38db92888f1ac232c2a90eef20546bd51f905404

Comment by Robert Stam [ 26/Oct/16 ]

This problem only seems to affect applications targeting the full .NET Framework.

For .NET Core, we already have an indirect dependency on System.Runtime.InteropServices.RuntimeInformation through the dependency on NETStandard.Library.

Comment by Robert Stam [ 22/Oct/16 ]

You can work around this bug by manually adding a dependency to the System.Runtime.InteropServices.RuntimeInformation Nuget package to your own project.

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