Wilduck
Wilduck

Reputation: 14136

Ironpython: Debugging a null reference exception

I have previously asked this question when I was seeing a null pointer exception. In that case it turned out that what I was seeing was in fact a bug in IronPython.

Now I recently came across this error again when using a third party library (written in C#). The library is the DotSpatial library and it turns out that I accidentally created a condition in my IronPython code that led to a side effect in the DotSpatial method breaking. For reference the call and error message are:

>>> myScheme.CreateCategories(myLayer.DataSet.DataTable) 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
SystemError: Object reference not set to an instance of an object.

This was particularly difficult to debug because the problem was not with the myScheme object or the DataTable I was passing to its method, but with another property of myScheme that I had set incorrectly, which I didn't even know that CreateCategories accessed.

To figure out what was going wrong here I had to read through the DotSpatial source code. While I don't have too much trouble doing that, I was wondering if there are any easier ways to debug such an error? Or am I stuck with bad error messages because I'm working with IronPython and a third party library?

Upvotes: 4

Views: 740

Answers (1)

Jeff Hardy
Jeff Hardy

Reputation: 7662

There are two command-line switches to get IronPython to show more exception information: -X:ExceptionDetail and -X:ShowClrExceptions. One or both of those should give you the full stack trace to where the NullReferenceException occurred.

Upvotes: 3

Related Questions