在视觉状态之间切换时 WPF 中出现致命运行时错误

发布于 2024-12-06 01:21:26 字数 281 浏览 2 评论 0原文

有时在特定情况下我总是会遇到此错误。当我从一种视觉状态切换到另一种视觉状态时,它就会发生。我认为它来自不良的属性动画,但我想知道发生此异常的条件是什么。 这是错误消息:

运行时遇到致命错误。错误的地址位于线程 0xabc 上的 0x58e3ba0d。错误代码为0x80131623。此错误可能是 CLR 中的错​​误或用户代码的不安全或不可验证部分中的错误。此错误的常见来源包括 COM 互操作或 PInvoke 的用户封送错误,这可能会损坏堆栈。

先感谢您

I keep having this error sometimes in a particular case. It happens precisely when I am switching from a visual state to another. I assume it comes from a bad property animation but I wonder what are the conditions in which this exception occurs.
Here is the error message:

The runtime has encountered a fatal error. The address of the error was at 0x58e3ba0d, on thread 0xabc. The error code is 0x80131623. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.

Thank you in advance

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

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

发布评论

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

评论(1

风筝在阴天搁浅。 2024-12-13 01:21:26

我想我找到了解释:在状态转换期间,我试图折叠部分用户界面。在这些部分中,有一些控件(按钮)附加了多种行为。

经过一些测试后,我注意到折叠具有附加行为的控件似乎会引发异常。折叠会删除对对象的引用,并且附加的行为会留下空引用,从而引发异常。
我不知道到底发生了什么,但我很确定这就是原因。这似乎也发生在“隐藏”的可见性中。所以我目前找到的唯一解决方法是降低控件的不透明度并将其高度设置为 0。

如果有人找到更好的方法来避免这个问题......

I think I found the explanation: During state transition, I was trying to collapse parts of the UI. Among these parts, there are some controls (buttons) that have several behaviors attached.

After some tests I noticed that collapsing a control that has a behavior attached seems to throw an exception. Collapsing deletes the reference to the object and the attached behavior is left with a null reference that makes it throwing an exception.
I don't know precisely what's happening, but I am pretty sure this is the cause. It seems to happen also with "hidden" visibility. So the only workaround I found for the moment is reducing the opacity of the control et setting its height to 0.

If someone found a better way to avoid this problem...

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