writexml-修改了收集;枚举操作可能无法执行

发布于 2025-01-28 19:10:39 字数 354 浏览 2 评论 0原文

我正在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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文