1
Answer

Throwing exception when reading mpp files

Madhu Sudhan

Madhu Sudhan

11y
2.1k
1
Hii,

I am trying to read Microsoft project plan files using c#.But when i try to read the .mpp file its throwing exception "Retrieving the COM class factory for component with CLSID {36D27C48-A1E8-11D3-BA55-00C04F72F325} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))." 

My code is 

  ApplicationClass projectApp = new ApplicationClass();

    // Open the file. There are a number of options in this constructor as you can see
            projectApp.FileOpen("c:\\Users\\madhu.sudhang\\b4ubuild_sample_07.mpp", true, Missing.Value, Missing.Value, Missing.Value,
    Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value,
    PjPoolOpen.pjDoNotOpenPool, Missing.Value, Missing.Value, Missing.Value, Missing.Value);

    // Get the active project 
    Project proj = projectApp.ActiveProject;

    // Enumerate the tasks
    foreach (Task task in proj.Tasks)
    {
    string name = task.Name;

    // Project stores the number of minutes in a workday, so 8 hours per workday * 60 = 480. 480 is a project "day"
    int duration_in_days = Int32.Parse(task.Duration.ToString()) / 480;

    DateTime start = DateTime.Parse(task.Start.ToString());
    DateTime finish = DateTime.Parse(task.Finish.ToString());
    double percent_complete = Double.Parse(task.PercentComplete.ToString());
    DateTime actual_finish = DateTime.Parse(task.ActualFinish.ToString());

    // Do something with each task here
      }

    // Make sure to clean up and close the file
    projectApp.FileCloseAll(PjSaveType.pjDoNotSave)

i kept break point and observed when creating  Application class object its throwing the exception.

Plz help me out of this.

Thanks & Regards

Madhu Sudhan

Answers (1)