This short guide explains how to set predecessor in MS Project using C#. It has details to set the IDE, a list of steps performed, and sample code demonstrating the complete process to work with the predecessor task using C#. You will also get a few ideas to improve this code if required.
Steps for Setting Predecessors in MS Project using C#
- Set the IDE to use Aspose.Tasks for .NET for predecessor tasks
- Set the license for saving the output as MPP
- Create a new project with a name and some tasks, say 5, representing stages of the project
- Set the duration of each task
- Link tasks 1,2, and 3 such that each task starts after the previous finishes
- Link tasks 3 and 4 by demonstrating a one-day lag
- Link task 4 and 5 so that task 5 starts after task 4 finishes
- Save the project on the disk and print all the tasks to observe the predecessors and successors
These steps summarize how to work with Microsoft Project successors using C#. Set the license, as saving a project in MPP format is not supported without a license. However, you may try other formats. Create a new empty project, add multiple tasks to it with defined durations, add linkages between different tasks, and add some lag if required. Finally, save the project and display all the predecessor and successor tasks.
Code for MS Project Predecessor using C#
This sample code describes the implementation of predecessor in Microsoft Project using C#. You may use constraints such as “Must Start On” or “As Soon As Possible” for more scheduling control. Usage of the project.CriticalPath assists in identifying and highlighting tasks that directly affect the project timelines.
This article teaches the functionality of predecessors and successors. To add a milestone in a project, refer to the article Add Milestone in MS Project using C#.