Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FileLoadException for System.Runtime.CompilerServices.Unsafe, when using System.memory #2563

Open
1 of 14 tasks
HamzaBA26 opened this issue Apr 18, 2024 · 0 comments
Open
1 of 14 tasks

Comments

@HamzaBA26
Copy link

Which version of Microsoft.IdentityModel are you using?
Note that to get help, you need to run the latest version.

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)

Issue found in Microsoft.IdentityModel.Protocols.OpenIdConnect 7.5.1

Is this a new or an existing app?

This is found in development, as we were upgrading Microsoft.IdentityModel.Protocols.OpenIdConnect to latest version, our tests ran into this issue.

Repro

  public class Tests
  {
    [SetUp]
    public void Setup()
    {
      var sd = new byte[] { 1, 2 };

      sd.AsSpan(0, 2);
    }

    [Test]
    public void Test1()
    {
      Assert.Pass();
    }
  }

Expected behavior

Expected being able to use System.Memory library while having Microsoft.IdentityModel.Protocols.OpenIdConnect referenced in a class library project.

Actual behavior

Throws an System.IO.FileLoadException : Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1

Possible solution

This seems only to be an issue for class libraries. If your project is Executable this does not seems to an issue. Workaround for class libraries is using the 'Microsoft.NET.Test.Sdk' library as this seems to fix the issue.

From my limited understanding is, that there is an event-handler in both the library 'Microsoft.NET.Test.Sdk' and the executable project. That looks up the GAC, to resolve the FileLoadException.

Additional context / logs / screenshots / links to code

The issue seems to be introduced for Microsoft.IdentityModel.Protocols.OpenIdConnect at version 6.23.0.

Here is a picture of a test project, which hits this issue.

image

@HamzaBA26 HamzaBA26 changed the title [Bug] FileLoadException for System.Runtime.CompilerServices.Unsafe, when using System.memory Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant