We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Aspose.Tasks Error Handling strategy


I have taken a bit of time doing other parts of the application as I continue to start testing and then get a bit stuck.

I cannot tell you how many times I've hit similar problems ... object not found; null exception occurred while reading an xml file.

When this error happens, I do not have any other option but to stop testing and report the problem which puts another month delay in completing integration of this component into live operation.

Can you possibly consider other strategies for error handling!!!!!!!

1) Raise an Event

Consider raising an event when reading an xml file and a problem is found. This should say what the XML TAG is and the value that is not correct. Allow a default to be provided or an ignore this error or some other options.

From a debugging point of view, I'd at least be able to see where the problem is coming from. Today, I have no idea where the fault is in the XML.

From a development point of view, I may provide a valid value and allow the loading to continue or I could allow the fault to be ignored.

At least, I can continue and possibly handle the error and provide a work around for the short term.

2) Keep a log of the problems that can be reviewed after the read operation.

Log the problems and keep going and allow the application to review the log and continue or report to the user. At least MS Project reads the entire XML and indicates problems.

3) Provide an error indication that a TAG has not been implemented yet.

If I know a tag has not been implemented yet, there are ways to filter them out of the xml before the file is read or a better option is to just pass these tags through (rather than potentially not load).

4) Provide an indication of any missing or expected tags

If something is missing, that is necessary, provide an indication of what is missing so this can be provided to the user (or used in testing). This can be provided in a log or return array of errors.

Please figure out a better strategy for 'object not found' or 'nullreferenceexceptions'. I cannot continue to have 1 month delays for a solution.

I would appreciate this being given some priority as I'm about to renew my license and still have not turned on this feature.

Thanks in advance..

Regards, Bruce

Hi Bruce,

Thank you a lot for such important comments and suggestions. I have to agree that we must provide customers with some information about the exceptions.

I have created a new issue ‘Provide customers with some information about XML parsing exception source.’ with ID = 16460 and linked it to this forum thread. In the beginning we can put XML element’s name to the exception message. We are planning to start the issue fixing in this month release.

Sorry for inconvenience.

Hi Sergey,

Excellent!!! It would be nice to know more than just the element name ... more like a stack trace with a good idea of the position in the file and the hierarchy in the xml.

I envision taking the exception information and adding this to the application error log so any user will be able to provide me with xml and error log and I can analyse.

I would really appreciate (my long term wish) is that the entire file (xml) would be processed and either generate an event for each problem (and I can consolidate, evaluate and cancel or continue) or return a log info package with all of the errors found and action taken after reading the entire file.

Anything would be an improvement over object not found or null reference.

As soon as you have a version available, I will try it and return results.

Regards, Bruce

Hi Bruce,

I have created the interim build and attached it to this thread. It provides some additional information about MPP or XML reading errors. You can use it like in the sample below:

<span lang=“EN-US” style=“font-size:10.0pt;font-family:“Courier New”;color:blue;
mso-ansi-language:EN-US;mso-no-proof:yes”>using<span lang=“EN-US” style=“font-size:10.0pt;font-family:“Courier New”;mso-ansi-language:EN-US;
mso-no-proof:yes”> System;<o:p></o:p>

using Aspose.Tasks;

namespace TestProjectReadingException


class Program


static void Main(string[] args)


License license = new License();


ProjectReader reader = new ProjectReader();

Project project;



project = reader.Read("Project2010as2007.mpp");


catch (TasksReadingException ex)






if (ex.InnerException != null)


Console.WriteLine("Inner exception message:");




catch (Exception ex)








For XML it provides the XML element path as well. I have changed some XML reading logic as well, so now elements like Type are not required. But of course without the data it is impossible to restore the complete project information.

Hi Sergey,

Many, many, many Thanks!!!!!!!

I can now read the full file w/o any errors. I injected two errors into the XML.

1) Change an End TAG

</SaveVersion> to


... no exception error - however, failed to load the project

2) Changed start date format


This generated the attached exception in the application error log... EXCELLENT!! This means all read errors are now tracked in the application error log!!! (with precise info about the fault).

How did you get the trace information???? That looks really good!!! However the exception is wonderful!!



Hi Bruce,

We do not check XML structure itself now. To check the XML schema you can just validate it against XSD.

In the first case we got exception before we have started XML parsing. We are checking only the values we are going to parse. I think it is enough for this case and it is not time consuming operation.

Thank you for cooperation very much!

Hi Sergey,

I thought it might be before the processing ... however, it is a fault and would be nice to know.

I have been thinking about the types of problems I've been seeing and have been thinking about doing some checking before reading and possible transforming after processing.

I can read and process the input XML (as I do this in my own app)... If I do this, I'll already have an XMLDocument ready for use.

As an item for the wish list, can there be a Read From an existing XML document overload and also write to an xmldocument rather than a file

This way, I can do some preprocessing or postprocessing as reading XML and writing XML is relataively easy once an XMLdocument is available.

Many thanks!!

Regards, Bruce

Hi Bruce,

Yes, I have to agree. I am going to update the message.

The second way to get the information is to check a log. The TasksReadingException has a string property LogText and in first case it contains information that XML loading was started but does not contain that it was finished.

The log is the main part for exception investigation for MPP files.

Thank you again.

The issues you have found earlier (filed as 16460) have been fixed in this update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.


Thank you for the updates to the help file. I now see the indication of which items are read from which source files. The information in the remarks section is very valuable.

Many thanks, Regards, Bruce