Hi there,
We are getting an exception of type System.InvalidOperationException, Message : Collection was modified; enumeration operation may not execute
while fetching Accesstoken and RefreshTokens via <RequestAccessAndRefreshTokensAsync>
stack trace:
System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
at System.Net.Http.Headers.HttpHeaders.AddHeaderInfo(String headerName, HeaderStoreItemInfo sourceInfo)
at System.Net.Http.Headers.HttpHeaders.AddHeaders(HttpHeaders sourceHeaders)
at System.Net.Http.Headers.HttpRequestHeaders.AddHeaders(HttpHeaders sourceHeaders)
at System.Net.Http.HttpClient.PrepareRequestMessage(HttpRequestMessage request)
at System.Net.Http.HttpClient.SendAsync(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.PostAsync(Uri requestUri, HttpContent content, CancellationToken cancellationToken)
at Microsoft.BingAds.Internal.HttpService.PostAsync(Uri requestUri, List`1 formValues, TimeSpan timeout) in D:\code\BingadsSDK_DotnetCore\src\BingadsSDK_DotnetCore\Internal\HttpService.cs:line 21
at Microsoft.BingAds.Internal.OAuth.UriOAuthService.<GetAccessTokensAsync>d__6.MoveNext() in D:\code\BingadsSDK_DotnetCore\src\BingadsSDK_DotnetCore\Internal\OAuth\UriOAuthService.cs:line 80
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.BingAds.Internal.OAuthWithAuthorizationCode.<RequestAccessAndRefreshTokensAsync>d__20.MoveNext() in D:\code\BingadsSDK_DotnetCore\src\BingadsSDK_DotnetCore\Internal\OAuthWithAuthorizationCode.cs
Also, the same method <RequestAccessAndRefreshTokensAsync> fails with another type of exception..
System.IndexOutOfRangeException: Index was outside the bounds of the array.
at System.Collections.Generic.List`1.Enumerator.MoveNext()
at System.Net.Http.Headers.HttpHeaders.AddHeaderInfo(String headerName, HeaderStoreItemInfo sourceInfo)
at System.Net.Http.Headers.HttpHeaders.AddHeaders(HttpHeaders sourceHeaders)
at System.Net.Http.Headers.HttpRequestHeaders.AddHeaders(HttpHeaders sourceHeaders)
at System.Net.Http.HttpClient.PrepareRequestMessage(HttpRequestMessage request)
at System.Net.Http.HttpClient.SendAsync(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.PostAsync(Uri requestUri, HttpContent content, CancellationToken cancellationToken)
at Microsoft.BingAds.Internal.HttpService.PostAsync(Uri requestUri, List`1 formValues, TimeSpan timeout)
at Microsoft.BingAds.Internal.OAuth.UriOAuthService.<GetAccessTokensAsync>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.BingAds.Internal.OAuthWithAuthorizationCode.<RequestAccessAndRefreshTokensAsync>d__20.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
These errors are not account/customer specific and occur across Microsoft ads customers.
Looking forward to hear from you... Thanks.