On executing File.LockFile(FolderID, 0), in a large batch, sometimes my automation is interupted by what seems to be a totally bogus error:
System.Runtime.InteropServices.COMException was unhandled
HelpLink="C:\Program Files\SolidWorks Enterprise PDM\api_gb.chm"
Message="The Archive Server could not find the file with the specified ID."
Source="SolidWorks Enterprise PDM"
at EdmLib.IEdmFile8.LockFile(Int32 lParentFolderID, Int32 lParentWnd, Int32 lEdmLockFlags)
at PDMETools.CustomPDMEAPI.CheckoutFile(IEdmFile8 PDME_File, Int32 PDME_FolderID, DateTime datAddDate) in C:\KentsVSProjects\PDMETools\PDMETools\CustomPDMEAPI.vb:line 117
at PDMETestConsoleApp.Module1.ImportToPDME() in C:\KentsVSProjects\PDMETools\PDMETestConsoleApp\Module1.vb:line 211
at PDMETestConsoleApp.Module1.Main() in C:\KentsVSProjects\PDMETools\PDMETestConsoleApp\Module1.vb:line 36
at System.AppDomain._nExecuteAssembly(Assembly assembly, String args)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
But, I already have a valid IEdmFile8 object with a name, ID, etc.
Function CheckoutFile(ByVal PDME_File As IEdmFile8, ByVal PDME_FolderID As Integer, ByVal datAddDate As Date) As Integer So, what is really happening? Kent
If Not PDME_File.IsLocked Then
PDME_File.LockFile(PDME_FolderID, 0) 'Error thrown here
Function CheckoutFile(ByVal PDME_File As IEdmFile8, ByVal PDME_FolderID As Integer, ByVal datAddDate As Date) As Integer
So, what is really happening?
Are you trying to lock an item (cutlist or item)? I've seen a similar error when attempting to work with a file that is actually an item. You can check with IEdmFile8.EdmFileType. Which leads me to my next question: has IEdmFile8 been fixed? (Casting to IEdmFile8 hasn't worked for me but I am not sure if that has been fixed in SP4.)