Handling Exceptions

Handling Exceptions While Working with Microsoft Project Files

When working with Microsoft Project (MPP) files using Aspose.Tasks for .NET, you may occasionally encounter exceptions due to unsupported features or unexpected project structures. In some cases, customers may prefer not to share project files for troubleshooting on our Support forums.

To assist in diagnosing such issues locally, the TasksReadingException class provides a LogText property. This property contains a textual log that can help identify the part of the project that triggered the exception—such as a specific task, resource, or resource assignment.

After isolating the problematic section using LogText, you may attempt to resolve the issue in your project file manually. Alternatively, you can extract and copy only the affected data to a separate project and share that with our support team if further assistance is needed.

The example below demonstrates how to catch and analyze a TasksReadingException when loading a project file:

 1Project project;
 2try
 3{
 4    project = new Project("New Project.mpp");
 5}
 6catch (TasksReadingException ex)
 7{
 8    Console.WriteLine("Message:");
 9    Console.WriteLine(ex.Message);
10    Console.WriteLine("Log:");
11    Console.WriteLine(ex.LogText);
12    if (ex.InnerException != null)
13    {
14        Console.WriteLine("Inner exception message:");
15        Console.WriteLine(ex.InnerException.Message);
16    }
17}

In this example, the LogText provides detailed insight into what went wrong during the project load operation. Additionally, inspecting the InnerException (if present) may reveal lower-level errors that contributed to the failure.

By using these diagnostics, developers can more effectively investigate issues without exposing sensitive project data. This approach improves troubleshooting while maintaining full control over proprietary information.

Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.