Handling Exceptions using Aspose.Tasks
Handling Exceptions While Working with Microsoft Project Files
Sometimes, Aspose customers are unable to load their projects because of unsupported features and other issues and do not want to share their projects for analysis on our Support forums.
The LogText property exposed by the TasksReadingException class is used to deal with such cases. You can use this property to identify the problematic section of the project, for example, a problematic task, resource, resource assignment etc.
After identifying the section that’s causing the problem, you can try to resolve the issue at your end or copy that data to a separate project and share with us to resolve the issue.
The following code example is used to identify the cause of the exception.
1System::SharedPtr<Project> project;
2try
3{
4 System::String dataDir = RunExamples::GetDataDir(System::Reflection::MethodBase::GetCurrentMethod(ASPOSE_CURRENT_FUNCTION)->get_DeclaringType().get_FullName());
5 project = System::MakeObject<Project>(dataDir + u"project.mpp");
6}
7catch (TasksReadingException& ex)
8{
9 System::Console::WriteLine(u"Message:");
10 System::Console::WriteLine(ex->get_Message());
11 System::Console::WriteLine(u"Log:");
12 System::Console::WriteLine(ex->get_LogText());
13 if (ex->get_InnerException() != nullptr)
14 {
15 System::Console::WriteLine(u"Inner exception message:");
16 System::Console::WriteLine(ex->get_InnerException()->get_Message());
17 }
18}
19catch (System::Exception& ex)
20{
21 System::Console::WriteLine(ex->get_Message());
22}
23