.NET 4 中模糊的 IndexOutOfRangeException

发布于 2024-10-29 22:16:32 字数 246 浏览 1 评论 0原文

我有一个 IndexOutOfRangeException,无法在调试模式下重现,根据抛出异常的堆栈跟踪,它发生在“return true;”行上。该行上没有数组索引,甚至过程中也没有任何数组索引,显然是抛出了异常。所以我猜测堆栈跟踪可能有点转移注意力。

有谁知道什么可能会导致这种行为?我确实有多个线程访问抛出异常的对象,但它们只是从对象中读取,没有进行任何修改。这可能仍然是一个问题吗?

任何关于我应该从哪里开始解决这个问题的指示将不胜感激。

I have an IndexOutOfRangeException that I can not reproduce in debug mode, according to the stack trace from where the exception is thrown it's occurring on the line "return true;" No array indexing on that line, and not even any array indexing in the procedure the exception is apparently being throw in. So I'm guessing the stack trace might be a bit of a red herring.

Does anyone know what might cause this behaviour? I do have multiple threads accessing the object in which the exception is being thrown, but they are only reading from the object, there are no modifications being made. Might this still be a problem?

Any pointers as to where I should start looking to fix this would be much appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

⒈起吃苦の倖褔 2024-11-05 22:16:32

您可能想在迭代之前制作本地副本,或者找到一种在迭代之前锁定集合的方法。

关于 C# 中线程使用的相当简单的阅读

(通常,是抛出异常的实际行之后的下一行)调试器中显示异常。)

You might want to make a local copy before iterating, or find a way to lock collection before iterating.

A fairly easy read on threading usage in C#

(Oftentimes, it's the next line after the actual line that throws exception is shown in debugger.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文