问题描述
我正在编写托管代码,并且正在为非托管库 (Qt) 使用托管绑定 (qt4dotnet).有时,我会从 Qt 的某个地方收到一个 AccessViolationException,但我不知道如何调试它.我什至没有得到比托管/非托管边界更远的堆栈跟踪(这意味着我不知道 Qt 的哪个部分在我身上崩溃了).
I'm writing managed code, and I'm using managed bindings (qt4dotnet) for an unmanaged library (Qt). Now and then, I get an AccessViolationException coming somewhere from Qt, but I don't know how to debug that. I don't even get a stacktrace further than the managed/unmanaged boundary (meaning I don't know what part of Qt crashed on me).
顺便说一下,我在 VS 调试器中运行我的应用程序.
By the way, I'm running my app inside the VS debugger.
如何调试异常?
推荐答案
Project + Properties,Debug 选项卡,勾选Enable unmanaged code debugging".这仍然不会让它变得容易,但至少你可以在它爆炸时查看非托管堆栈帧.确保您有 Qt 代码的 .pdb 文件.
Project + Properties, Debug tab, tick "Enable unmanaged code debugging". This still won't make it easy, but at least you can look at the unmanaged stack frames when it bombs. Make sure you've got the .pdb files for the Qt code.
这篇关于如何调试来自本机代码的 AccessViolationException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!