none
Project PlugIn Comexception by Working with TimeScaleData object RRS feed

  • Question

  • Hello Everybody,

    I have a Problem with the TimeScaleValue.Value Property. The get_Value Method always rise an COMException. It's not possible to set any value to this property.

    Here a an Extract of the Code:

                    foreach (MSProject.Assignment assn in resource.Assignments)
                    {
                      data = dataList[assn.Guid.ToLower()];
                      tSVs = assn.TimeScaleData(data.Workdate, data.Workdate, Microsoft.Office.Interop.MSProject.PjAssignmentTimescaledData.pjAssignmentTimescaledActualWork, Microsoft.Office.Interop.MSProject.PjTimescaleUnit.pjTimescaleDays, 1);
                      foreach (MSProject.TimeScaleValue tSV in tSVs)
                      {
                        tSV.Value = data.Hours * 60;
                      }
                    }

    I found this, but this had no effect.

    http://www.projectserverexperts.com/ProjectServerFAQKnowledgeBase/SolveCOMExceptionError.aspx

    Thanks for any Help

    Friday, July 2, 2010 7:22 AM

Answers

  • Hi Jan.

    Thank you, for your Answer. I found the Solution in an other forum. I had to call GC.Collect in foreach and one time more after foreach. For example:

            foreach (MSProject.Assignment assn in resource.Assignments)
            {
             data = dataList[assn.Guid.ToLower()];
             tSVs = assn.TimeScaleData(data.Workdate, data.Workdate, Microsoft.Office.Interop.MSProject.PjAssignmentTimescaledData.pjAssignmentTimescaledActualWork, Microsoft.Office.Interop.MSProject.PjTimescaleUnit.pjTimescaleDays, 1);
             foreach (MSProject.TimeScaleValue tSV in tSVs)
             {
              tSV.Value = data.Hours * 60;
              GC.Collect();
             }
             tSVs = null;
             GC.Collect();
            }
    
    

    The problem is the TimeScaleValue and TimeScaleValues types. She wont disposing by Garbage Collector automatically.

    Monday, August 23, 2010 2:55 PM

All replies

  • Hi Richard,

    I've used these objects many, many times but alwys in VBA.

    Nevertheless, just a few thoughts.

    You do not mention whether you use Project Server or not. Project Server has a setting forbidding the entry of Actual Work in Professional. Could that be the case?

    You mention the get_value method which I do not know and which does not appear in your code. Which statement throws the error then?

    From memory i'm not sure that would throw an error but is Workdate a working day?

    Greetings,

    Friday, July 2, 2010 11:32 AM
    Moderator
  • Hi Jan.

    Thank you, for your Answer. I found the Solution in an other forum. I had to call GC.Collect in foreach and one time more after foreach. For example:

            foreach (MSProject.Assignment assn in resource.Assignments)
            {
             data = dataList[assn.Guid.ToLower()];
             tSVs = assn.TimeScaleData(data.Workdate, data.Workdate, Microsoft.Office.Interop.MSProject.PjAssignmentTimescaledData.pjAssignmentTimescaledActualWork, Microsoft.Office.Interop.MSProject.PjTimescaleUnit.pjTimescaleDays, 1);
             foreach (MSProject.TimeScaleValue tSV in tSVs)
             {
              tSV.Value = data.Hours * 60;
              GC.Collect();
             }
             tSVs = null;
             GC.Collect();
            }
    
    

    The problem is the TimeScaleValue and TimeScaleValues types. She wont disposing by Garbage Collector automatically.

    Monday, August 23, 2010 2:55 PM