NullReferenceException,没有堆栈跟踪...从哪里开始? [英] NullReferenceException, no stack trace... where to start?
问题描述
我有一个WPF音频应用程序。
I have a WPF audio application.
偶尔(甚至在调试器中)我看到一个 NullReferenceException
它不带有堆栈跟踪信息。
Occasionally (and even in the debugger) I'm seeing a NullReferenceException
which carries no stack trace information with it.
如何开始调试这样的问题?
How can one start debugging such an issue?
一些背景:
我是P $调用 WinMM.dll
中的函数,涉及注册回拨,当调用 waveOutOpen
I'm P/Invoking functions in WinMM.dll
which involves registering a callback when calling waveOutOpen
[DllImport("winmm.dll")]
public static extern MmResult waveOutOpen(out IntPtr phwo, IntPtr uDeviceID, WaveFmt pwfx, WaveCallbk dwCallback, IntPtr dwInstance, int fdwOpen);
这证明难以稳定,特别是在我调用 waveOutClose
,并立即调用 waveOutOpen
(通常更改输出格式)。
This has proved difficult to get stable, especially at the point where I call waveOutClose
, and immediately call waveOutOpen
again (usually to change the output format).
我怀疑这个问题可能与上面描述的电话有关(尽管知之甚少,我可以完全失去目标)。
I suspect that the problem may be related to the calls I've been describing above (although on so little knowlege, I could be completely off-target).
复制目前的问题是难以捉摸的,虽然我可以为一个相当一贯地看到这个问题的用户提供一个构建。我可能会尝试加速导致问题的操作,以便在调试器中再现问题更加确定。
Reproducing the problem is currently proving elusive, although I can supply a build to a user who is fairly consistently seeing this problem. I might try to speed up the operations that are causing the problem to the point where reproducing the problem in the debugger is more of a certainty.
关于调试器,我没有修改任何设置(包括启用非托管代码调试
)或任何 Debug - >例外...
设置。说实话,我对这里提供的东西很无聊,所以欢迎任何提示。
With regards to the debugger, I haven't tinkered with any of the settings (including Enable unmanaged code debugging
) or any of the Debug -> Exceptions...
settings. To be honest, I'm fairly clueless about what's on offer here, so any hints are welcome.
异常怎么可能没有堆栈跟踪?你以前见过吗?帮助!
How might an exception not have a stack trace? Have you seen this before? Help!
推荐答案
在调试器中可以做的最有用的工作是指示它打破第一次机会异常(Debug - >异常):
The most helpful thing you can do in the debugger is instruct it to break on a first-chance exception (Debug -> Exceptions):
这将导致调试器的一个中断,确切地说,一个 NullReferenceException
被抛出,这几乎是最好的您可以希望在调试时。
This will cause a break into the debugger at the exact point a NullReferenceException
is thrown, which is pretty much the best you can ever hope for while debugging.
这篇关于NullReferenceException,没有堆栈跟踪...从哪里开始?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!