Skip to content

Assembly Microsoft.AspNetCore.Cryptography.KeyDerivation fails to load when running on Linux #41368

@madmox

Description

@madmox

I recently migrated my ASP.NET Core website from .NET Core 3.1 to .NET 6, and since the migration I get a runtime exception when referencing classes in the Microsoft.AspNetCore.Cryptography.KeyDerivation assembly when running under my production server on Linux Debian (no issue on Windows or in the Bitbucket pipeline which also runs a Linux container, mcr.microsoft.com/dotnet/sdk:6.0):

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.AspNetCore.Cryptography.KeyDerivation, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.

More infos about the production environment:

  • Debian version: Debian GNU/Linux 10 (buster)
  • Kernel Version: Linux 4.19.0-9-amd64 #1 SMP Debian 4.19.118-2 (2020-04-29)
  • .NET runtime version: 6.0.1
  • Microsoft.AspNetCore.Cryptography.KeyDerivation nuget package version: 6.0.1 (explicit reference in the csproj of the class library subproject throwing the exception)
  • The website root does not contain any Microsoft.AspNetCore.Cryptography.KeyDerivation assembly.

Might be related to this issue.

The issue disappeared when I updated the Microsoft.AspNetCore.Cryptography.KeyDerivation nuget package from 6.0.1 to 6.0.4 because the assembly now gets copied to the publish folder when I build on the production server. It seems the assembly is not copied when the .NET runtime and Microsoft.AspNetCore.Cryptography.KeyDerivation nuget versions match, but is copied when the nuget version is greater. This would mean I will get the error back when I update my .NET runtime to 6.0.4 and deploy again.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions