在视觉状态之间切换时 WPF 中出现致命运行时错误
有时在特定情况下我总是会遇到此错误。当我从一种视觉状态切换到另一种视觉状态时,它就会发生。我认为它来自不良的属性动画,但我想知道发生此异常的条件是什么。 这是错误消息:
运行时遇到致命错误。错误的地址位于线程 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想我找到了解释:在状态转换期间,我试图折叠部分用户界面。在这些部分中,有一些控件(按钮)附加了多种行为。
经过一些测试后,我注意到折叠具有附加行为的控件似乎会引发异常。折叠会删除对对象的引用,并且附加的行为会留下空引用,从而引发异常。
我不知道到底发生了什么,但我很确定这就是原因。这似乎也发生在“隐藏”的可见性中。所以我目前找到的唯一解决方法是降低控件的不透明度并将其高度设置为 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...