The following line of code is causing me an Exception
using (new INVU.API.CallContextStore())
{
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 have been attempting to debug this for hours now, while I’ve learned a lot about how this particular program works I haven’t really gotten anywhere.
I got some responses to an question earlier regarding using debugging information, which seemed to confirm my initial thought on the Exception.
Correctly using stacktrace to debug
Now, at first I assumed the SimsBridge object was not being initialized but I have since found where in the code this happens (takes user/pass as parameters). I am successfully logged in at this point and details from the server are returned and displayed on my form.
(None of the parameters are null either)
A network error was my other suspicion, as I’ve seen the exe installer packaged of this program working. So it should work.
However the fact I can login goes against this…
I am feeling a bit lost on where to look next and there is literally no one working here I can ask.
Q: What would be your next step in attempting to tracking down the cause of this problem?

If none of the parameters are null (all of those
val_things) and neitherplugor.Instanceare null, then the fault may lie internally in theAddDocumentsmethod. If you are not in control of this code (for example, it’s third party) then all you can do is make sure you are using the code correctly. Otherwise you are stuck posting a question to the authors of the library.All you know is, something somewhere is null. None of your stuff appears to be null (aside from potentially
DatabaseName) so that only leaves the internal state of the method you are calling.For me, the next step would be to create a small application that does nothing other than what you are trying to do (
AddDocumentsin this case) to see if you can get it working, or replicate the issue again. If you can get it working, it’s then a case of code reviewing the original stuff to see if you have made a slight logical error anywhere. If you can replicate it, post that to the code authors as a question and see what they say.