question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BCrypt version 4.0.2 and System.Runtime.CompilerServices.Runtime 4.7.1 compatibility issue

See original GitHub issue

My team is using BCrypt version 4.0.2 and we’ve to use v4.7.1 of System.Runtime.CompilerServices.Unsafe due to another (transitive) dependency.

At runtime, we see the following error when invoking the BCrypt.Net.BCrypt.HashPassword(String inputKey, String salt, Boolean enhancedEntropy, HashType hashType) method.

[16:54:50]F:			 [MM.Core.NUnitTests.UnitTests.BusinessLayerTests.HelperTests.PasswordHashingHelperTests.GenerateHash_given_password_and_salt_returns_hashed_value] System.IO.FileLoadException : Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, 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)
[16:54:50]F:			 [MM.Core.NUnitTests.UnitTests.BusinessLayerTests.HelperTests.PasswordHashingHelperTests.GenerateHash_given_password_and_salt_returns_hashed_value]    at System.ReadOnlySpan`1..ctor(T[] array)
   at System.ReadOnlySpan`1.op_Implicit(T[] array)
   at BCrypt.Net.BCrypt.HashPassword(String inputKey, String salt, Boolean enhancedEntropy, HashType hashType) in I:\bcrypt.net\src\BCrypt.Net\BCrypt.cs:line 669
   at MM.Core.BusinessLayer.Helpers.PasswordHashingHelper.GenerateHash(String password, String salt) in C:\BuildAgent\work\50ad46f03ff53e94\Core\BusinessLayer\Helpers\PasswordHashingHelper.cs:line 23
   at MM.Core.NUnitTests.UnitTests.BusinessLayerTests.HelperTests.PasswordHashingHelperTests.GenerateHash_given_password_and_salt_returns_hashed_value() in C:\BuildAgent\work\50ad46f03ff53e94\Core\NUnitTests\UnitTests\BusinessLayerTests\HelperTests\PasswordHashingHelperTests.cs:line 69

(Assembly) version 4.0.4.1 is part of System.Runtime.CompilerServices.Unsafe v4.5.3, I believe.

According to Nuget v4.0.2 documentation, it depends on System.Memory >= v4.5.4 which in turn depends on System.Runtime.CompilerServices.Unsafe >= 4.5.4. This means it should work with v4.7.1, but doesn’t seem to.

Has version 4.0.2 BCrypt been tested with version 4.7.1 of System.Runtime.CompilerServices.Unsafe?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
ChrisMcKeecommented, Apr 13, 2021

I switched to xunit when nunit stagnated (post .net core launch after DNX); .net assembly binding is my endless hell 😆

1reaction
jijoecommented, Apr 13, 2021

So it turns out this problem we caused by use of Nunit 3 runner for our unit tests step in TeamCity builds. Switching to vstest for unit test step fixed this problem for us.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Could not load file or assembly System.Runtime. ...
It seems that you have installed System.Runtime.CompilerServices.Unsafe nuget package 4.5.3 version. And it corresponds to System.Runtime.
Read more >
Could not load file or assembly System.Runtime. ...
Hi all, I have been bashing my head trying to get a fix for a tricky binding error that get thrown when attempting...
Read more >
NuGet Warning NU1605
NET Core 1.0 and 1.1 are not compatible with each other when they are referenced together in a .NET Core 3.0 or higher...
Read more >
Ivan Neurons for ITSM Software Atribu on Report
Client Runtime for Microsoft Azure Libraries 3.3.10 : MIT License ... compatibility-v4 19.1.0 : Apache License 2.0, Common Development and Distribution ...
Read more >
Third Party Licenses
Name Version Description json‑schema‑0.4.0.tgz 0.4.0 JSON Schema validation and specifications doctrine‑2.1.0.tgz 2.1.0 JSDoc parser combokeys‑3.0.1.tgz 3.0.1 Handles keyboard shortcuts in the browser
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found