c# - 正确使用 stacktrace 进行调试

标签 c# exception stack-trace

下面这行代码导致了异常

plug.Instance.AddDocuments(new Int32[] { val_pid }, val_ptype, val_doccat, val_subcat, val_doctype, val_notes, val_summary, SummaryAppendOptions.None, val_docStatus, new String[] { PDFFile })

这是异常的详细信息。

System.Exception was caught
 Message=Object reference not set to an instance of an object. - Error when trying to save    document
 Source=SimsBridge

 StackTrace:
   at SimsBridge.Bridge.AddDocuments(Int32[] personIds, Int32 PersonType, String docCatagory, Int32 subCatagory, String docType, String notes, String summary, SummaryAppendOptions summaryOptions, String documentStatusCode, String[] filePaths)
   at ManagedScanDesktop.Form1.SimsScanComplete(String[] files) in C:\Working\ManagedScanDesktop 1.8\v1.8\ManagedScanDesktop\ManagedScanDesktop\Form1.cs:line 2619
InnerException: 

我不是在寻找实际异常的解决方案。

我的问题是,堆栈跟踪是否指向方法的哪一部分没有引用集?还是stacktrace只是为了追踪调用方法的位置?

最佳答案

堆栈跟踪显示抛出异常时的调用堆栈。根据您提供的内容,您只能推断出 AddDocuments 引发了异常。传入的任何引用类型参数都可以为 null。查明问题的最佳方法是设置断点,而不是检查值。

关于c# - 正确使用 stacktrace 进行调试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9707058/

相关文章:

python - Django/psycopg2/postgresql 可能损坏的模型给出了无用的堆栈跟踪

c# - 等价于 ContinueWith(delegate, CancellationToken) with await continuation

C# MouseHover 上的按钮透明背景

sockets - Indy - ReadLnSplit 关闭时导致 NotConnected 异常

c++ - 通过 VCL 异常例程捕获 C++ 异常

windows-8.1 - 仅为提供程序中的某些特定 ETW 任务激活堆栈?

java - 如何将已编译jsp类的行号映射到原始源代码?

c# - 带有回调的 .NET 异步 Web 服务调用

c# - 空格和 oledb

c++ - 为什么异常规范没有用?