title: Missing Assembly Reference Using Microsoft.IdentityModel.Clients.ActiveDirectory 3.13.9 with Azure KeyVault C# SDK
body: <p>For some reason, I have to latest <code>Microsoft.IdentityModel.Clients.ActiveDirectory</code> <a href="https://www.nuget.org/packages/Microsoft.IdentityModel.Clients.ActiveDirectory" rel="nofollow noreferrer">v3.13.9</a> with <code>Microsoft.Azure.KeyVault</code> <a href="https://www.nuget.org/packages/Microsoft.Azure.KeyVault" rel="nofollow noreferrer">v2.0.6</a>. And it always throws exceptions for missing assembly reference, but downgrading <code>Microsoft.IdentityModel.Clients.ActiveDirectory</code> to v2.28.4, which I'm not allowed to use, can resolve this <a href="https://github.com/AzureAD/azure-activedirectory-library-for-dotnet/issues/511" rel="nofollow noreferrer">known issue</a>.</p>
  
  <p>Here's the exception:</p>
  
  <pre><code>  InnerException:
     HResult=-2146233036
     Message=The type initializer for 'Microsoft.IdentityModel.Clients.ActiveDirectory.PlatformPlugin' threw an exception.
     Source=Microsoft.IdentityModel.Clients.ActiveDirectory
     TypeName=Microsoft.IdentityModel.Clients.ActiveDirectory.PlatformPlugin
     StackTrace:
          at Microsoft.IdentityModel.Clients.ActiveDirectory.PlatformPlugin.get_Logger()
          at Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext..cctor()
     InnerException:
          ErrorCode=assembly_not_found
          HResult=-2146233088
          Message=Assembly required for the platform not found. Make sure assembly 'Microsoft.IdentityModel.Clients.ActiveDirectory.Platform, Version=3.12.0.827, Culture=neutral, PublicKeyToken=31bf3856ad364e35' exists
          Source=Microsoft.IdentityModel.Clients.ActiveDirectory
          StackTrace:
               at Microsoft.IdentityModel.Clients.ActiveDirectory.PlatformPlugin.LoadPlatformSpecificAssembly()
               at Microsoft.IdentityModel.Clients.ActiveDirectory.PlatformPlugin.InitializeByAssemblyDynamicLinking()
               at Microsoft.IdentityModel.Clients.ActiveDirectory.PlatformPlugin..cctor()
          InnerException:
               FileName=Microsoft.IdentityModel.Clients.ActiveDirectory.Platform, Version=3.12.0.827, Culture=neutral, PublicKeyToken=31bf3856ad364e35
               FusionLog==== Pre-bind state information ===
  </code></pre>
  
  <p>Code snippets:</p>
  
  <pre><code>    protected KeyVaultBase(string clientId, string clientSecret)
      {
          if (string.IsNullOrWhiteSpace(clientId))
          {
              throw new ArgumentNullException(nameof(clientId));
          }
  
          if (string.IsNullOrWhiteSpace(clientSecret))
          {
              throw new ArgumentNullException(nameof(clientSecret));
          }
  
          this.KeyVaultClient = new KeyVaultClient(
              new KeyVaultClient.AuthenticationCallback(
                  (authority, resource, scope) =&gt; GetAccessToken(authority, resource, scope, clientId, clientSecret)
              )
          );
      }
  
      private static async Task&lt;string&gt; GetAccessToken(string authority, string resource, string scope, string clientId, string clientSecret)
      {
          var authnContext = new AuthenticationContext(authority);
          var clientCredential = new ClientCredential(clientId, clientSecret);
          var result = await authnContext.AcquireTokenAsync(resource, clientCredential);
  
          if (result == null)
          {
              throw new InvalidOperationException("Failed to obtain the JWT token");
          }
  
          return result.AccessToken;
      }
  </code></pre>
  
  <p>The exception throws while executing <code>var authnContext = new AuthenticationContext(authority);</code>. </p>
  
  <p>Does anyone know any solution/workaround to resolve this issue without the downgrading?</p>