joniles/mpxj

Crash when trying to import Phoenix file from V5.6.3

Closed this issue · 4 comments

I just downloaded the latest Phoenix version (5.6.3) and am having trouble opening some files I produced from it. All the sample files (compressed and not compressed) work fine, but the ones I generated do not.

A file is attached (zipped to be allowed)
Current Schedule.zip
and it gives me a System.NullReferenceException: 'Object reference not set to an instance of an object.' error. in String.cs because @this is null. Here is the stack trace.

image

Hi, can you confirm which version of MPXJ you are working with?

Thank you! I had a quick look with the Java version which seemed to read the sample file OK, I'll create a test .NET 4.8 project to see if I can reproduce.

I had a closer look at this and have found and fixed the issue. The underlying problem was that the activity total_cost and billed attributes, which I'd previously only seen with integer zero values (0), were represented as decimal zero values in your sample file (0.0000). The number parse error is what was triggering the null pointer exception, however this was being handled by JAXB (the XML binding library MPXJ uses) and was silently ignored. If you had ignored the exception being thrown within the library the file would have read ok.

I've updated Phoenix schemas to ensure that these monetary attributes are represented as double, which ensures that the relevant attributes are read correctly, and thus stops the exception from being raised. This change will be in the next MPXJ release.

This issue suggests that we may encounter other places where monetary values are not being read correctly, but I have yet to encounter any sample Phoenix projects which contain cost data. If I have a chance I will look at generating some...

In the meantime it's worth noting that JAXB has some version checking code which raises, and handles a null pointer exception, which you'll see at least once when MPXJ first reads an XML file. This can safely be ignored.