Free Support Forum -

Setting Gantt task view as default view for entire project when saing MPP file (C# .NET)

Hi Team,
Am looking for options to save a MPP file using

ProjectSave(“FilePath”, new MPPSaveOptions() { WriteViewData = true });

with default view set as Gantt view and zoom to “Entire project” always.
Please let me know the options with aspose to achieve this.

Thank you.


Please try the following code sample:

GanttChartView view = (GanttChartView)project.DefaultView;
// This code is added for better visualization
view.MiddleTimescaleTier.Unit = TimescaleUnit.Days; 

You can apply different TimescaleUnits as per your requirements.

GanttChartView view = (GanttChartView)project.DefaultView;

  • Throws exception when I have DefaultView as ResourceView, so wanted to know how to set default view as Gantt chart view.

view.MiddleTimescaleTier.Unit = TimescaleUnit.Days;

  • For my use case I wanted to set it as Quarters, but same is not being set in the saved MPP file.


Can you please mention what kind of exception is thrown.
Moreover, we have logged an issue with issue ID “TASKSNET-2737” for further investigation while using Quarters as TimescaleUnit. You will automatically be informed here once we have more information to share.

Here is the exception up on type casting

System.InvalidCastException: ‘Unable to cast object of type ‘Aspose.Tasks.View’ to type ‘Aspose.Tasks.GanttChartView’.’


We have logged these details under issue ID “TASKSNET-2737” and will be considered during the issue resolution.

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