Error caching CRMServiceClient connection string from Microsoft Dynamics CRM SDK

Caching the latest versions of the Dynamics SDK is driving me crazy.

First, if you want to use CrmServiceClient to access different environments, you must use the parameter RequireNewInstance=True;in the connection string. If not, then each instance of CrmServiceClient will use the same connection, even if you create and host the instances in different environments.

Now, even if you use RequireNewInstance=True;the connection string, I found that the cache is still found in some scenarios.

var client1 = new CrmServiceClient("RequireNewInstance=True;
Url=https://myCompany.crm.dynamics.com;
Username=myUser@myCompany.onmicrosoft.com; Password=myPassowrd;
AuthType=Office365");

//Now, client 2 points to a url that doesnt exists:
var client2 = new CrmServiceClient("RequireNewInstance=True; 
Url=https://xxx.crm.dynamics.com; Username=myUser@myCompany.onmicrosoft.com; 
Password=myPassowrd; AuthType=Office365");

Client2 continues to use the first connection string, so you cannot determine if the new connection string is correct.

, Dynamics Crm asp.net?

+4
3

, . , - Dynamics 365, .

, URL- , - CRM, URL- .

:

var client1 = new CrmServiceClient("RequireNewInstance=True; 
Url=https://fake.crm.dynamics.com; 
Username=myUser@myCompany.onmicrosoft.com; Password=myPassowrd; 
AuthType=Office365");

"" URL- , , CrmServiceClient.

(, 2015, , - CRM ..), IsReady CrmServiceClient false, LastCrmError.

, . , , , , , , , .

+1

, , RequireNewInstance=true, , , . LinqPad crmSvcClient2, , ref Execute ( SDK 8.2.0.2). SDK LastCrmError , , .

var connectionString = @"AuthType=Office365;Url=https://REAL.crm.dynamics.com;Username=USERNAME;Password=PASSWORD;RequireNewInstance=True;";
var connectionString2 = @"AuthType=Office365;Url=https://FAKE.crm.dynamics.com;Username=USERNAME;Password=PASSWORD;RequireNewInstance=True;";   

using (var crmSvcClient = new CrmServiceClient(connectionString))
{
    "crmSvcClient".Dump();
    crmSvcClient.LastCrmError.Dump();
    ((WhoAmIResponse)crmSvcClient.Execute(new WhoAmIRequest())).OrganizationId.Dump();
    crmSvcClient.ConnectedOrgFriendlyName.Dump();


}
using (var crmSvcClient2 = new CrmServiceClient(connectionString2))
{
    "crmSvcClient2".Dump();
    crmSvcClient2.LastCrmError.Dump();
    ((WhoAmIResponse)crmSvcClient2.Execute(new WhoAmIRequest())).OrganizationId.Dump();
    crmSvcClient2.ConnectedOrgFriendlyName.Dump();
}

enter image description here

+1

, , , , URL- , . , SkipDiscovery = True :

var connectionString2 = @ "AuthType = Office365; Url = https: //FAKE.crm.dynamics.com; Username = USERNAME; Password = PASSWORD; RequireNewInstance = True; SkipDiscovery = True;";

Change: SkipDiscovery defaults to true starting from 9.0.7, glory @mwardm

0
source

Source: https://habr.com/ru/post/1667998/


All Articles