Use stacktrace properly for debugging

The following line of code throws 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 details of the exception.

 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 am not looking for a solution for the actual exception.

My question is, does the stacktrace point indicate which part of the method does not have a set of links? Or is stacktrace just keeping track of where the method is being called?

+4
source share
3 answers

The stack trace shows the call stack when an exception is thrown. From what you have provided, you can only infer that the exception was AddDocuments from AddDocuments . Any of the passed parameters of the reference type may be null. The best way to identify problems is to set a breakpoint and check the values.

+4
source

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

+1
source

The message says that somewhere in AddDocuments exception with a null reference is thrown. This can be one of the parameters or a member.

+1
source

Source: https://habr.com/ru/post/1401434/


All Articles