When using the following code:
Dim modiDocument As New MODI.Document
modiDocument.Create(TifFile)
modiDocument.Close(False)
Then the TifFile isn't locked and I can do things like e.g. delete it (IO.File.Delete).
However when I enumerate the Images then the file will be locked:
Dim modiDocument As New MODI.Document
modiDocument.Create(TifFile)
For Each modiImage In modiDocument.Images
'Doesn't matter if I enter code here or not.
Next
modiDocument.Close(False)
Now the file will be locked.
I tried everything (I think) to solve this, like:
Dim modiDocument As New MODI.Document
modiDocument.Create(TifFile)
For Each modiImage In modiDocument.Images
Marshal.ReleaseComObject(modiImage)
Next
Marshal.ReleaseComObject(modiImage)
modiDocument.Close(False)
Marshal.ReleaseComObject(modiDocument)
Yes, I also tried FinalReleaseComObject.
So far, no luck.
How can I solve this?
NB: The example here are in VB. I also know C#, so it doesn't matter in which language you provide code examples.