6 Replies Latest reply on Aug 17, 2010 11:26 PM by Jeff Sweeney

    PDME API varEnum.CloseFile corrupts AutoCAD file, DwgFmtServer.exe Causes Sharing violation

    Kent Keller

      I am cycling through AutoCAD files in a custom Import routine that has successfully worked for 5958 files.

       

      However, on some, seemingly random cases, when I make a call to update custom variables using this vb.net code

       

      Dim varEnum As IEdmEnumeratorVariable8 ' declare enumerator
      varEnum = ThisFile.GetEnumeratorVariable ' set to destination file
      varEnum.SetVar("Description", "", strDescription) ' set variable
      varEnum.SetVar("Number", "", strNumber) ' set variable
      varEnum.SetVar("Make_Buy", "", strMake_Buy) ' set variable
      varEnum.SetVar("Supplier", "", strSupplier) ' set variable
      varEnum.SetVar("SupplierID", "", strSupplier_ID) ' set variable
      varEnum.SetVar("DwgType", "", strDwgType) ' set variable
      varEnum.SetVar("DPGC", "", strDPGC) ' set variable
      varEnum.SetVar("DSGC", "", strDSGC) ' set variable
      varEnum.SetVar("DTGC", "", strDTGC) ' set variable
      varEnum.CloseFile(True) ' close file

       

      I get a com exeption

       

      System.Runtime.InteropServices.COMException was unhandled
      ErrorCode=-2147417851

      Message="The server threw an exception."

       

      At this point, the PDME Checked out file goes to 0 bytes and DwgFmtServer.exe locks the file.  No checkout, no open, no file replace.  If I undo the checkout, it will restore the file but will be unable to be opened due to a sharing violation.

       

      In short, I'm borked.

       

      Why is DwgFmtServer.exe locking the file?  Is there any API that I can use to close it?  Error handling on this seems impossible?

       

      Any suggestions out there?

       

      Kent