'WriteXml - Collection was modified; enumeration operation might not execute
I'm coding in Visual Studio 2019 and I get the following error message: "Collection was modified; enumeration operation might not execute". It happens when I try to save a dataset with the method WriteXml:
myDataset.WriteXml(myPath)
Due to the fact that I modify the dataset with other methods connected to events, maybe the modification could happens during the WriteXml, but to avoid this situation I fisrt copy the dataset and then use the second dataset for the WriteXml:
Dim myDs As DataSet = myDataset
myDs.WriteXml(myPath)
Could somebody help me? Thank you
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|