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

Could not load file or assembly ‘Microsoft.IdentityModel.Abstractions, Version=6.35.0.0. Nuget version mismatch Microsoft.IdentityModel.Abstractions #110865

Open
FrostNeptune opened this issue Dec 20, 2024 · 2 comments
Labels
area-Infrastructure-libraries untriaged New issue has not been triaged by the area owner

Comments

@FrostNeptune
Copy link

I am developing a C# dll based on .NET framework 4.8.2 which will use Microsoft Graph API to send email through outlook.
For this I have added the latest Nuget packages for “Microsoft.Graph” v5.67.0 and "Microsoft.Identity.Client" v4.66.2 . This is my csproj -

<ItemGroup>
    <PackageReference Include="Microsoft.Graph">
      <Version>5.67.0</Version>
    </PackageReference>
    <PackageReference Include="Microsoft.Identity.Client">
      <Version>4.66.2</Version>
    </PackageReference>
    <PackageReference Include="Microsoft.Windows.Compatibility">
      <Version>9.0.0</Version>
    </PackageReference>
    <PackageReference Include="Newtonsoft.Json">
      <Version>13.0.1</Version>
    </PackageReference>
    <PackageReference Include="Std.UriTemplate" Version="2.0.1.0" />
    <PackageReference Include="Microsoft.CSharp">
      <Version>4.7.0</Version>
    </PackageReference>
  </ItemGroup>

The build is successfull but I am getting this runtime error -

### System.IO.FileLoadException: Could not load file or assembly ‘Microsoft.IdentityModel.Abstractions, Version=6.35.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’ or one of its dependencies. The located assembly’s manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: ‘Microsoft.IdentityModel.Abstractions, Version=6.35.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’

Now, “Microsoft.Graph” v5.67.0 is dependent upon latest 'Microsoft.IdentityModel.Abstractions, Version=8.2.0.0 but I am not able to figure out which module is dependent upon 6.35.0.0.

Upon further looking, it is found out that, in obj/project.asset.json file there is a mismatch between 'Microsoft.IdentityModel components. “Microsoft.Graph.Core/3.2.1” is referring to “Microsoft.IdentityModel.Validators”: “8.2.0” but "Microsoft.Identity.Client/4.66.2"is referring to old 6.35.0 version.

Here is the obj/project.asset.json file -

"Microsoft.Graph/5.67.0": {
        "type": "package",
        "dependencies": {
          "Microsoft.Graph.Core": "3.2.1"
        },

"Microsoft.Graph.Core/3.2.1": {
        "type": "package",
        "dependencies": {
          "Microsoft.IdentityModel.Protocols.OpenIdConnect": "8.2.0",
          "Microsoft.IdentityModel.Validators": "8.2.0",
          "Microsoft.Kiota.Abstractions": "1.15.2",
          "Microsoft.Kiota.Authentication.Azure": "1.15.2",
          "Microsoft.Kiota.Http.HttpClientLibrary": "1.15.2",
          "Microsoft.Kiota.Serialization.Form": "1.14.0",
          "Microsoft.Kiota.Serialization.Json": "1.15.2",
          "Microsoft.Kiota.Serialization.Multipart": "1.14.0",
          "Microsoft.Kiota.Serialization.Text": "1.14.0",
          "System.Net.Http.WinHttpHandler": "6.0.0"
        },

"Microsoft.Identity.Client/4.66.2": {
        "type": "package",
        "dependencies": {
          "Microsoft.IdentityModel.Abstractions": "6.35.0",
          "System.Diagnostics.DiagnosticSource": "6.0.1"
        },

In Microsoft.Identity.Client/4.66.2 release note it is mentioned that it will work with “Microsoft.IdentityModel.Abstractions” >= 6.35.0 but in reality it is not.
Please advise me how to fix this error

@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Dec 20, 2024
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-infrastructure-libraries
See info in area-owners.md if you want to be subscribed.

@huoyaoyuan
Copy link
Member

NuGet versioning and assembly versioning are different systems. .NET Framework requires exact assembly version match. You need to ensure binding redirect is properly generated for the entry application.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Infrastructure-libraries untriaged New issue has not been triaged by the area owner
Projects
None yet
Development

No branches or pull requests

2 participants