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.

KeyVault 2.2 nuget: Could not load file or assembly 'Microsoft.IdentityModel.Clients.ActiveDirectory.Platform'

See original GitHub issue

Describe the bug

I utilize one library that requires Microsoft.IdentityModel.Clients.ActiveDirectory >= 4.5.0, however starting with version >= 4 of that library, the dependency namespace ‘Microsoft.IdentityModel.Clients.ActiveDirectory.Platform’ is no longer listed.

The Microsoft.Extensions.Configuration.AzureKeyVault v2.2.0 nuget package requires Microsoft.IdentityModel.Clients.ActiveDirectory >= 3.14.x which does have the required dependency namespace ‘Microsoft.IdentityModel.Clients.ActiveDirectory.Platform’

Microsoft.Extensions.Configuration.AzureKeyVault v2.2.0 crashes on not finding the ‘Microsoft.IdentityModel.Clients.ActiveDirectory.Platform’ dependency because in my solution I am using Microsoft.IdentityModel.Clients.ActiveDirectory v4.5.0.

I cannot downgrade Microsoft.IdentityModel.Clients.ActiveDirectory to 3.19.8 as alot of posts have suggested because my other dependency requires >= 4.5.0.

To Reproduce

Steps to reproduce the behavior:

  1. Use version ‘2.2.0’ of package ‘Microsoft.Extensions.Configuration.AzureKeyVault’
  2. Use version ‘4.4.3’ of package ‘Microsoft.Bot.Builder’
  3. Run this StatelessService code in a .net core project:
protected override IEnumerable<ServiceInstanceListener> CreateServiceInstanceListeners()
{
    return new ServiceInstanceListener[]
    {
        new ServiceInstanceListener(serviceContext =>
            new KestrelCommunicationListener(serviceContext, "ServiceEndpoint", (url, listener) =>
            {
                ServiceEventSource.Current.ServiceMessage(serviceContext, $"Starting Kestrel on {url}");
                return WebHost.CreateDefaultBuilder()
                    .ConfigureAppConfiguration((context, config) =>
                    {
                            var keyVaultName = "<KEYVAULT NAME>";
                            var azureServiceTokenProvider = new AzureServiceTokenProvider();
                            var keyVaultClient = new KeyVaultClient(new KeyVaultClient.AuthenticationCallback(azureServiceTokenProvider.KeyVaultTokenCallback));
                            config.AddAzureKeyVault(keyVaultName, keyVaultClient, new DefaultKeyVaultSecretManager());
                    })
                    .ConfigureServices(
                        services => services
                            .AddSingleton<StatelessServiceContext>(serviceContext))
                    .UseStartup<Startup>()
                    .UseServiceFabricIntegration(listener, ServiceFabricIntegrationOptions.None)
                    .UseUrls(url)
                    .Build();
            })),
    };
}

Expected behavior

Service starts up and runs.

Failing behavior is that FileNotFoundException is thrown with error Could not load file or assembly ‘Microsoft.IdentityModel.Clients.ActiveDirectory.Platform’

Additional context

Add any other context about the problem here.

$ dotnet --info
Zestaw .NET Core SDK (odzwierciedlenie dowolnego pliku global.json):
 Version:   2.2.106
 Commit:    aa79b139a8

Srodowisko uruchomieniowe:
 OS Name:     Windows
 OS Version:  10.0.17763
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.2.106\

Host (useful for support):
  Version: 2.2.4
  Commit:  f95848e524

.NET Core SDKs installed:
  1.0.0-preview2-003131 [C:\Program Files\dotnet\sdk]
  1.0.0 [C:\Program Files\dotnet\sdk]
  1.0.4 [C:\Program Files\dotnet\sdk]
  1.1.0 [C:\Program Files\dotnet\sdk]
  2.1.101 [C:\Program Files\dotnet\sdk]
  2.1.202 [C:\Program Files\dotnet\sdk]
  2.1.402 [C:\Program Files\dotnet\sdk]
  2.1.403 [C:\Program Files\dotnet\sdk]
  2.1.500 [C:\Program Files\dotnet\sdk]
  2.1.502 [C:\Program Files\dotnet\sdk]
  2.1.505 [C:\Program Files\dotnet\sdk]
  2.2.106 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 1.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.1.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:21 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
gsacavdmcommented, Jan 6, 2020

I don’t think that’s an option for me as I’m running on dotnet core 3.1 and the 3.14.2 DLL isn’t compatible with that from what I understand.

Moreover, I’m interested in a response from the ASPNet team on the proper fix for this.

2reactions
aidapsibrcommented, Feb 14, 2020

Just ran into this as well. The problem is sinister because .Platform it isn’t listed as a direct dependency of anything other than AppAuth. However, forcing AppAuth to 1.4 doesn’t help as something in the configuration extensions IS referencing platform without stating it’s dependency as direct.

Even if this wasn’t breaking, this should be fixed to help customers align various dependency chains where possible.

Read more comments on GitHub >

github_iconTop Results From Across the Web

KeyVault 2.2 nuget: Could not load file or assembly ' ...
Describe the bug I utilize one library that requires Microsoft.IdentityModel.Clients.ActiveDirectory >= 4.5.0, however starting with version ...
Read more >
Could not load file or assembly 'Microsoft.IdentityModel. ...
I have installed one nuget package called Microsoft.CrmSdk.XrmTooling.CoreAssembly it has installed default package Microsoft.IdentityModel.
Read more >
"Could not load file or assembly 'Microsoft.Identity.Client ...
The reason I dont just use the latest version is because the ExchangeOnlineModule wants this version specificly. If the installation did not ......
Read more >
[Solved] Could not load file or assembly 'Microsoft. ...
The Solution:​​ This error comes because of Version mismatch in Assemblies of Microsoft Core Assemblies and Project . NET Framework.
Read more >
Microsoft.IdentityModel.Clients.ActiveDirectory 5.3.0
Please note, a newer package is available Microsoft.Identity.Client. This package will continue to receive critical bug fixes until December 2022, we strongly ...
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