WriteXml - Collection was modified; enumeration operation might not execute

20 views Asked by At

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

0

There are 0 answers