1 Reply Latest reply on Oct 15, 2015 3:55 PM by Nicolas Ziegler

    The object invoked has disconnected from its clients

    Arne Morten Fredriksen



      I'm trying to create an ePDM addin that handles rebuilding, and reopening of a drawing inside SolidWorks.

      The code is executed at the EdmCmd_PostState event in ePDM. After the code has executed the drawing has change state, it has been rebuilded and everything looks alright. But, an error message is thrown every time and the ePDM task pane inside SolidWorks is not updated.


      The error message says:

      Could not Change the State of the file.


      Description='The object invoked has disconnected from its clients.'


      I have commented the part of the code who is responsible for the error to appear.

      Here is the stripped down code:


      Case EdmCmdType.EdmCmd_PostState

           'Get file and folder object.

           Dim oFile As EdmLib.IEdmFile7 = oVault.GetObject(EdmLib.EdmObjectType.EdmObject_File, ppoData(nIndex).mlObjectID1)

           Dim oFolder As EdmLib.IEdmFolder6 = oVault.GetObject(EdmLib.EdmObjectType.EdmObject_Folder, ppoData(nIndex).mlObjectID2)


           'Full file path.

           Dim sFullFilePath As String = "C:\TestVault\CAD\Part1.slddrw"


           'Get latest version of the file.

           oFile.GetFileCopy(0, 0)


           'Check the file out.

           oFile.LockFile(oFolder.ID, 0)


           'Connect to SolidWorks.

           Dim oSolidWorksApplication As Object = Nothing

           oSolidWorksApplication = GetObject(, "SldWorks.Application")


           'Activate the drawing document in SolidWorks.

           Dim nError As Integer

           Dim oDocument As SldWorks.ModelDoc2

           oDocument = oSolidWorksApplication.ActivateDoc2(sFullFilePath, True, nError)


           'Rebuild drawing.



           'Save the rebuilded drawing.



           'Reopen the document in SolidWorks.

           Dim nOption As System.Int32 = 0

           Dim nValue As System.Int32

           Dim oNewDoc As SldWorks.ModelDoc2 = Nothing



           nValue = DirectCast(oSolidWorksApplication, SldWorks.SldWorks).CloseAndReopen(oDocument, nOption, oNewDoc) 'The return value nValue is 0 meaning nothing went wrong.



           oDocument = Nothing

           oNewDoc = Nothing


           'Check in the document.

           oFile.UnlockFile(0, "Saved Rebuilded drawing")



           oSolidWorksApplication = Nothing







      Does anyone have a clue of what is happening here???

      I have debugged this for 2 days now without any result.

      Any help will be appreciated.


      Thanks in advance.

        • Re: The object invoked has disconnected from its clients
          Nicolas Ziegler

          I was trying to do exactly the same thing and got the same error...


          I think the problem comes from the way the hook works:

          EdmCmdType.EdmCmd_PostState The user changes the workflow state of a file.

          I think it means that the state is changing but has not completely changed yet.


          What happens is when you execute your rebuild code, the change of state is on hold and when your block of code is executed, it finishes the change of state.

          The thing is that you disconnect the file with the CloseAndReopen and I suppose that EPDM cannot finish to change the state hence the 'The object invoked has disconnected from its clients.'


          Your post is from 1year ago, have you found any workaround?