Let my file go!
Since PDMWorks Enterprise 2008 will not support custom applications written in VB6, I know a lot of you are busy converting your code to .NET. Here is a little “gotcha” to watch out for:
I had a little routine that would write to a file’s datacard at check in time. [EdmCmd_PreUnlock] It worked great in VB6 but when I converted it to .NET, PDMWorks Enterprise could not finish the check in operation telling me that the file was in use by another process.
I wept openly for about two hours before I finally found this little diddy in the help file:
The IEdmEnumeratorVariable interfaces are designed to keep the file open while the interface exists. This means that other operations on the file may fail with sharing violations while the interface exists. The recommendation in PWE 2008 and later is to always call the IEdmEnumeratorVariable8.CloseFile method when you are finished updating a file. The call will make it possible for other applications and API-functions to access the file again. This recommendation replaces the earlier work-arounds to explicitly clear IEdmEnumeratorVariable pointers (set them to Nothing in Visual Basic) and to call Marshal.ReleaseComObject in .Net applications.
The weird thing was that I was already setting my object = Nothing, but it still didn’t matter. (Nor did GC.Collect) When I added the suggested “CloseFile” method, all went smoothly!