Ironpython: debugging a null reference exception

I previously asked this question when I saw a null pointer exception. In this case, it turned out that what I saw was actually a bug in IronPython.

Now, I recently encountered this error when using a third-party library (written in C #). The library is a DotSpatial library, and it turns out that I accidentally created a condition in my IronPython code, which led to a side effect in Violating the DotSpatial method. For reference message and error message:

>>> 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 especially difficult to debug, because the problem was not that the myScheme or DataTable object that I passed it to the method, but with the other myScheme property that I set incorrectly, that I did not even know that the CreateCategories had access.

To understand what was going on here, I had to read the source code of DotSpatial . While I have no particular problems with this, I was wondering if there are 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?

+4
source share
1 answer

There are two command line switches to force IronPython to display more information about exceptions: -X:ExceptionDetail and -X:ShowClrExceptions . One or both of these should give you a complete trace of the stack where a NullReferenceException occurred.

+3
source

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


All Articles