Could not load file or assembly 'Microsoft.IdentityModel.Clients.ActiveDirectory.Platform'

I have a Xamarin.iOS project and I want to authenticate with Azure. The end goal is to not have the user login, and to authenticate behind the scenes. When I instantiate AuththenticationContext I get this Error. "Could not load file or assembly 'Microsoft.IdentityModel.Clients.ActiveDirectory.Platform'". I installed Microsoft.IndentityModel.Clients.ActiveDirectory v3.13.9 from Nuget and the using statement is at the top of the code. The DLL is set to copy local. I don't know why this is not working. I even unintalled the Nuget Package and added the DLL's to the project and referenced them directly and got the same error. Below is the code that I am trying to make work. Again it breaks when AuthenticationContext is instantiated so I cant even test the rest of it. I have used the following two websites for guidance,

I found this "bug" here, but the fix does not work, nor does it make sense to me. Im not sure where to put the code and I get the access error as well.

var authContext = new AuthenticationContext(aadInstance);
ClientCredential clientCredential = new ClientCredential(clientId, appKey);

        // ADAL includes an in memory cache, so this call will only send a message to the server if the cached token is expired.
             AuthenticationResult result =  authContext.AcquireTokenAsync(AMServiceResourceId, clientCredential).Result;

        WebRequest Request =
                new Uri(@<API call to test connection>));
        Request.ContentType = "application/json";
        Request.Method = "Get";
        Request.Proxy = null;
        Request.Timeout = 5000;
        Request.Headers.Add("Authorization", "Bearer" + result.AccessToken);

Best Answer


  • ReidWilliams.7469ReidWilliams.7469 USMember ✭✭

    That worked. Thank you so much for your help.

  • PiyaliSilPiyaliSil USMember

    Hi ,

    Have anyone used com.Microsoft.adalcache in Xamarin ios for SSO feature

Sign In or Register to comment.