Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Not able to connect Dynamics 365 Unified Interface by using "Microsoft.CrmSdk.XrmTooling.CoreAssembly" in C#

We are trying to connect Dynamics 365 Unified Interface instance via C# code (WebAPI hosted at Azure) using Microsoft.CrmSdk.XrmTooling.CoreAssembly with the parameters ClientId and ClientSecret. but we are getting below error.

"Unable to connect to CRM: Method not found: 'System.String Microsoft.Xrm.Sdk.Organization.OrganizationDetail.get_EnvironmentId()'. Method not found: 'System.String Microsoft.Xrm.Sdk.Organization.OrganizationDetail.get_EnvironmentId()'.Unable to Login to Dynamics CRM Unable to Login to Dynamics CRMOrganizationWebProxyClient is null OrganizationWebProxyClient is null"

Please note, we have used latest NuGet version of "Microsoft.CrmSdk.XrmTooling.CoreAssembly" with the Framework 4.6.2.

Below is the code that we have written

System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;

    IOrganizationService organizationService = null;

    string organizationURI = "https://OrgName.api.crm.dynamics.com/XRMServices/2011/Organization.svc";
    string clientId = "Clientid";
    string clientSecret = "ClientSecret";

    var connection = new CrmServiceClient($@"AuthType=ClientSecret;url={organizationURI};ClientId={clientId};ClientSecret={clientSecret}");

    if (connection.IsReady)
    {
      organizationService = connection.OrganizationWebProxyClient != null ? connection.OrganizationWebProxyClient : (IOrganizationService)connection.OrganizationServiceProxy;
    }
like image 397
Inkey Solutions Avatar asked Oct 23 '25 14:10

Inkey Solutions


2 Answers

I had the same problem and after I deleted every .dll file and reinstalled them, it worked. So, I guess you have a problem with a .dll-version.

like image 160
Dennis Rieke Avatar answered Oct 26 '25 05:10

Dennis Rieke


I needed to use Microsoft.CrmSdk.XrmTooling.CoreAssembly 9.1.0.25 for compatibility with Azure Functions v1's old Newtonsoft.Json version, and was getting this error until I installed a newer version of Microsoft.CrmSdk.CoreAssembly (the newest version at the time worked, 9.0.2.27 and 9.0.2.33 in two different apps).

like image 29
vvv Avatar answered Oct 26 '25 03:10

vvv



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!