Visual Studio Developer Center > Visual Studio Forums > Visual Studio Tools for Office > How to get peakunits of resources from MS Project 2003 using c#.Net
Ask a questionAsk a question
 

AnswerHow to get peakunits of resources from MS Project 2003 using c#.Net

  • Wednesday, March 14, 2007 2:33 PMSuresh.Gidugu Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hi to All

    Me Suresh,

    written  below code for getting the peakunits of all resources from MS Project File.

    But getting only few values and in the middle got the following Exception

    "Exception from HRESULT: 0x800A03EC".

    //-------------------------------------------------------------------

    object oMV = Missing.Value;

    MSProject.Application msp = new MSProject.Application();

    msp.FileOpen(@"C:\Agra Bypass Analysis.mpp", false, oMV, oMV, oMV, oMV, oMV, oMV, oMV, oMV, oMV, MSProject.PjPoolOpen.pjPoolReadWrite, oMV, oMV, oMV, oMV);

    foreach (MSProject.Resource res in msp.ActiveProject.Resources)

    {

    MSProject.TimeScaleValues tsvs = res.TimeScaleData(msp.ActiveProject.Start, msp.ActiveProject.Finish, MSProject.PjResourceTimescaledData.pjResourceTimescaledPeakUnits, MSProject.PjTimescaleUnit.pjTimescaleYears, 1);

    foreach(MSProject.TimeScaleValue tsv in tsvs)

    {

    try

    {

    MessageBox.Show(res.Name + ": " + tsv.Value.ToString());

    }

    catch (Exception ex)

    {

    MessageBox.Show(ex.ToString());

    }

    }

    }

    //--------------------------------------------------

    I shall be great full if you  provide me solution to the mentioned problem.

    waiting for your reply as soon as possible.

    Thanking you very much

    Suresh.Gidugu

Answers

All Replies

  • Monday, September 24, 2007 8:33 AMVISSARION Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hi Sureh,

     

    Try this :

     

    bool error;

    object o;

    foreach(MSProject.TimeScaleValue tsv in tsvs)

    {

    error = true;

    while (error)

    try

    {

    o = tsv.Value;

    MessageBox.Show(res.Name + ": " + o.ToString());

    error = false;

    }

    catch(Exception ex) // 0x800A03EC

    {

    error = true;

    }

    }

    }

     

    It takes time but it works!

     

    I'm trying to sort out this problem for a very long period and this is the only solution I found!

    I'll be very happy if you have found any other solution

     

    Best Regards

     

    Vissarion

    GREECE

  • Saturday, November 07, 2009 2:40 PMSuresh.Gidugu Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    put GC.Collect();  Before Going into for loop.
    then working fine.
    Suresh G Kumar
    • Marked As Answer bySuresh.Gidugu Saturday, November 07, 2009 2:40 PM
    •