writexml-修改了收集;枚举操作可能无法执行
我正在Visual Studio 2019中进行编码,并收到以下错误消息:“ 收集已修改;枚举操作可能无法执行”。 当我尝试使用方法writexml的数据集保存数据集时,就会发生这种情况:
myDataset.WriteXml(myPath)
由于我使用与事件连接的其他方法修改数据集的事实,也许修改可能在Writexml期间发生,但是为了避免这种情况,我会复制数据集和数据集和然后将第二个数据集用于writexml:
Dim myDs As DataSet = myDataset
myDs.WriteXml(myPath)
有人可以帮我吗?谢谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论