0

I have recently migrated from Microsoft.Xrm.Tooling.Connector to Microsoft.PowerPlatform.Dataverse.Client as part of .NET 6 migration, and updated all the references from CRMServiceClient to ServiceClient as mentioned in the below link.

https://learn.microsoft.com/en-us/power-apps/developer/data-platform/sdk-client-transition

I am seeing a caching issue with MaxRetryCount and RetryPauseProperty properties. Whenever, I create a new ServiceClient, it is picking up the previously stored values. I an ensuring to Dispose service client and set it to null as well, but no use.

How to ensure that these properties retrieve the default values instead of cached values.

We have similar question posted in the below link, but no valid answer was provided yet. ServiceClient Caching Resutls

Below is a sample snippet that I am trying.

public ServiceClient GetServiceClient(int maxRetryCount, TimeSpan retryPauseProperty)
{
   var serviceClient = new ServiceClient("myconnectionstring");
   serviceClient.MaxRetryCount = maxRetryCount;
   serviceClient.RetryPauseProperty = retryPauseProperty;
   return serviceClient;
}

public void test()
{
 var sc = GetServiceClient(5, new TimeSpan(200));
sc.Dispose();
sc = null;
sc = GetServiceClient(10, new TimeSpan(100)); //retrieves 5 and 200 as MaxRetryCount and RetryPauseProperty instead of 10 and 100
}

0 Answers0