none
Exception when trying to update a dependency RRS feed

  • Question

  • I am using MS Project 2010 and VS 2010 with C# and the Microsoft.Office.Interop.MSProject version 14. When I try to update a Task Dependency I get an exception System.Runtime.InteropServices.COMException: The argument value is not valid.

    I can create a Task Dependency but not update it.

    Here is a sameple of code (I know that I can set these when creating the dependency but that is only a sample, I do not always create it):

    TaskDependency oDependency = oTask.TaskDependencies.Add(oPredecessorTask);
    oDependency.Lag = "0"; // Exception
    oDependency.Type = (PjTaskLinkType)oDbTaskDependency.TaskLinkType; // Exception

     

     

     

     

     

     

    • Edited by JFC Dev Friday, May 28, 2010 6:08 PM code was not displayed properly
    Friday, May 28, 2010 6:04 PM

Answers

  • OK, let's give it another try.

    First have you tried 0 instead of "0"? In VBA the conversion is done but is it in your world?

    Second, I simply don't understand the syntax of the line odependency.type.

    Could you try one of the available constants there? (pjstarttostart, etc.)?

    Tuesday, June 1, 2010 1:12 PM
    Moderator

All replies

  • Hello,

     

    Don't know any C, so tried it in VBA. The following definitely works:

    Sub tds()
    Set td = ActiveProject.Tasks(4).TaskDependencies.Add(ActiveProject.Tasks(1))
    td.Lag = "480"
    td.Type = pjFinishToFinish
    End Sub

    I DO get execptions, however, if both tasks are already linked, then td is not created. Could that be your problem?

     

    Greetings,

    Friday, May 28, 2010 9:04 PM
    Moderator
  • No the dependency doesn't already exist and the exception is when I try to assign the values, not when I create it (Add).
    Monday, May 31, 2010 6:01 PM
  • OK, let's give it another try.

    First have you tried 0 instead of "0"? In VBA the conversion is done but is it in your world?

    Second, I simply don't understand the syntax of the line odependency.type.

    Could you try one of the available constants there? (pjstarttostart, etc.)?

    Tuesday, June 1, 2010 1:12 PM
    Moderator