Amazon-SP-API-CSharp icon indicating copy to clipboard operation
Amazon-SP-API-CSharp copied to clipboard

Collection was modified; enumeration operation may not execute

Open Lemodo20 opened this issue 2 years ago • 2 comments

Hi,

i upload several files in own threads to Amazon. After a few request i get on this line of code (i use vb.net) an error

Dim feedOutput = amazonConnection.Feed.GetFeed(feedresultTXT)

System.InvalidOperationException: "Collection was modified; enumeration operation may not execute."

based on my knowledge, each thread should have his own variable an so it can't be, that one thread is overwriting the data of another thread?

Any idea, where the problem came from?

As the error came from above line, which is based on your c# api, i can't even access the resources, which you use there....

Lemodo20 avatar Oct 11 '23 14:10 Lemodo20

After importing your project into Visual Studio i can point out the exact line of code, where this happens: public virtual string ExtractSignedHeaders(RestRequest request) { List<string> rawHeaders = request.Parameters.Where(parameter => ParameterType.HttpHeader.Equals(parameter.Type)) .Select(header => header.Name.Trim().ToLowerInvariant()) .ToList(); rawHeaders.Sort(StringComparer.OrdinalIgnoreCase); return string.Join(";", rawHeaders); }

The line List<string> rawHeaders = request.Parameters.Where(parameter => ParameterType.HttpHeader.Equals(parameter.Type)) .Select(header => header.Name.Trim().ToLowerInvariant()) .ToList(); is shown as the source of the problem.

Lemodo20 avatar Oct 12 '23 08:10 Lemodo20

@abuzuhri close?

kevinvenclovas avatar Apr 23 '24 12:04 kevinvenclovas