Skip to content

[Bug] "Could not load file or assembly 'Microsoft.Bcl.Memory, Version=9" on .net 8 #3179

Closed
@j-hudecek

Description

@j-hudecek

Which version of Microsoft.IdentityModel are you using?

Microsoft.IdentityModel 8.6.1

Where is the issue?

  • M.IM.JsonWebTokens
  • M.IM.KeyVaultExtensions
  • M.IM.Logging
  • M.IM.ManagedKeyVaultSecurityKey
  • M.IM.Protocols
  • M.IM.Protocols.OpenIdConnect
  • M.IM.Protocols.SignedHttpRequest
  • M.IM.Protocols.WsFederation
  • M.IM.TestExtensions
  • M.IM.Tokens
  • M.IM.Tokens.Saml
  • M.IM.Validators
  • M.IM.Xml
  • S.IM.Tokens.Jwt
  • Other (please describe)

Is this a new or an existing app?

The app is in production with 8.1.2 and I have upgraded to a new version of Microsoft.IdentityModel.*

Repro

var tokenDescriptor = new SecurityTokenDescriptor
            {
                Subject = new ClaimsIdentity(GetClaims()),
                NotBefore = now,
                Expires = ExpiryDate,
                IssuedAt = now,
                SigningCredentials = new SigningCredentials(
                    Settings.JWTKey,
                    SecurityAlgorithms.HmacSha256Signature),
            };

var token = tokenHandler.CreateToken(tokenDescriptor);

Expected behavior
Token gets created

Actual behavior


File name: 'Microsoft.Bcl.Memory, Version=9.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
   at Microsoft.IdentityModel.Tokens.Base64UrlEncoder.Encode(Byte[] inArray, Int32 offset, Int32 length)
   at Microsoft.IdentityModel.Tokens.Base64UrlEncoder.Encode(Byte[] inArray)
   at Microsoft.IdentityModel.Tokens.Base64UrlEncoder.Encode(String arg)
   at System.IdentityModel.Tokens.Jwt.JwtHeader.Base64UrlEncode()
   at System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.CreateJwtSecurityTokenPrivate(SecurityTokenDescriptor tokenDescriptor)
   at System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.CreateToken(SecurityTokenDescriptor tokenDescriptor)

Possible solution

Additional context / logs / screenshots / links to code
It works on Ubuntu 22 and 24 but breaks on RHEL 8.6 and Rocky 8.10. Downgrading to 8.1.2 solves this problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugProduct is not functioning as expectedP2High, but not urgent. Needs to be addressed within the next couple of sprints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions