Invalid object ID when requesting WorkFlow.InitialState

Hi all,

i don't know if this is the right section to post this. Sorry for that.

I'm developing some Addin for Enterprise PDM 2011 using VB.Net language and 3.5 framework. Whenever I try to know which is the initial state of a cartain workflow i alway get the same error (Invalid Object ID). <-- translated from italian, i hope it's correct.

Here is the code I used:

        Dim EnumVarSelFile As EdmLib.IEdmEnumeratorVariable8
        Dim Mystring As String = ""
        Dim WorkFlowMgr As IEdmWorkflowMgr6
        Dim WorkFlow As IEdmWorkflow6
        Dim state As IEdmState6
        Dim pos As IEdmPos5
        WorkFlowMgr = Vault
        pos = WorkFlowMgr.GetFirstWorkflowPosition
        'look for the workflow i need
        While Not pos.IsNull
            WorkFlow = WorkFlowMgr.GetNextWorkflow(pos)
            If WorkFlow.Name = "MyWorkFlow" Then
                Exit While
            End If
        End While
        state = WorkFlow.InitialState

I really need help.

Thanks

SolidworksApi macros