Correctly using stacktrace to debug

牧云@^-^@ 提交于 2019-12-23 12:28:26

问题


The following line of code is causing me an Exception

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 })

And this is the exception detail.

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: 

I'm not looking for a solution to the actual exception.

My question is, does the stacktrace point to which part of the method doesn't have a reference set? Or is stacktrace just to trace to where the method is called?


回答1:


The stack trace shows you the call stack when an exception is thrown. From what you've provided you can only deduce that an exception was thrown from AddDocuments. Any of the reference type parameters passed in could be null. The best way to pinpoint the problems is to set a breakpoint and than inspect the values.




回答2:


Your stack trace means that either SimsBridge or SimsBridge.Bridge is null.




回答3:


The message is telling you that somewhere in AddDocuments a null reference exception was thrown. It could be one of the parameters or a member.



来源:https://stackoverflow.com/questions/9707058/correctly-using-stacktrace-to-debug

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!