7

I am trying to connect on premises Dynamic CRM 2016 from asp.net Web Project. I am using CrmServiceClient method with Active Directory Authentication Mode.

I am getting following exception.

{"Could not load type 'Microsoft.IdentityModel.Clients.ActiveDirectory.PromptBehavior' from assembly 'Microsoft.IdentityModel.Clients.ActiveDirectory, Version=3.10.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.":"Microsoft.IdentityModel.Clients.ActiveDirectory.PromptBehavior"}

new CrmServiceClient(
    new System.Net.NetworkCredential("adminuser", "pass", "domain"), 
    Microsoft.Xrm.Tooling.Connector.AuthenticationType.AD, 
    "http://sample.com", "4466", "DEV", useUniqueInstance:false, 
    useSsl:false)

Also Tried this

new CrmServiceClient(ConfigurationManager.ConnectionStrings["CRM_CONN"].ConnectionString)
Filburt
  • 17,626
  • 12
  • 64
  • 115
  • Could you please show the your code? – Filburt Jun 28 '16 at 12:28
  • @Filburt any suggestion? – Ahmed Abdullah Saeed Jun 28 '16 at 13:36
  • Did you make sure Microsoft.IdentityModel.Clients.ActiveDirectory.dll is in place? It sounds like this DLL is missing or maybe blocked by Security Policy because you copied it from a network location. – Filburt Jun 28 '16 at 13:43
  • It is there, visual studio was giving me exception of this dll. I have added current version 3.10 using nuget. After that it is giving me this exception. It seems that it is internal issue of dll. – Ahmed Abdullah Saeed Jun 28 '16 at 13:57
  • 1
    I'd recommend to use the assemblies provided by "crmsdk" in nuget - they should contain correct version. I used them in a console application with the connection string you tried in your second example. My Microsoft.IdentityModel.Clients.ActiveDirectory.dll has version 2.18.20625.1556. – Filburt Jun 28 '16 at 14:09

1 Answers1

9

Edited, i found the solution.

I had to downgrade: Microsoft.IdentityModel.Clients.ActiveDirectory to version 2.27 to get this working. The newer versions i tested had the same error.

Hope this works for you also!