-
Notifications
You must be signed in to change notification settings - Fork 54
Description
PowerPlatform-DataverseServiceClient/src/GeneralTools/DataverseClient/Client/Utils/Utils.cs
Lines 1097 to 1111 in dc278e3
internal static string GetCookiesFromCollectionAsString(Dictionary<string, string> cookieCollection) | |
{ | |
if (cookieCollection == null || cookieCollection.Count == 0) | |
return string.Empty; | |
string cookieString = ""; | |
if (cookieCollection != null) | |
{ | |
foreach (var itm in cookieCollection) | |
{ | |
cookieString += $"{itm.Key}={itm.Value};"; | |
} | |
} | |
return cookieString; | |
} |
My application uses multithreading and sometimes such an error occurs "Collection was modified; enumeration operation may not execute.", most likely since I use multithreading, then at the same time in the execution of this method, "cookieCollection" changes in another thread, which is why this error occurs.
StackTrace:
at System.Collections.Generic.Dictionary2.Enumerator.MoveNext() at Microsoft.PowerPlatform.Dataverse.Client.Utilities.GetCookiesFromCollectionAsString(Dictionary
2 cookieCollection)
at Microsoft.PowerPlatform.Dataverse.Client.DataverseTelemetryBehaviors.BeforeSendRequest(Message& request, IClientChannel channel)
at System.ServiceModel.Dispatcher.ImmutableClientRuntime.BeforeSendRequest(ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.PrepareCall(ProxyOperationRuntime operation, Boolean oneway, ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(MethodCall methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(MethodInfo targetMethod, Object[] args)
--- End of stack trace from previous location where exception was thrown ---
at System.Reflection.DispatchProxyGenerator.Invoke(Object[] args)
at generatedProxy_1.Execute(OrganizationRequest )
at Microsoft.PowerPlatform.Dataverse.Client.Connector.WebProxyClientAsync1.ExecuteAction[TResult](Func
1 action)
at Microsoft.PowerPlatform.Dataverse.Client.ServiceClient.Command_Execute(OrganizationRequest req, String errorStringCheck, Boolean bypassPluginExecution)