开发者

Ironpython: Debugging a null reference exception

开发者 https://www.devze.com 2023-03-31 05:51 出处:网络
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.

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 w开发者_如何学Cas 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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消