I have a C# .netFramework4.8 COM INTEROP library that takes data and puts it into a .pdf file to be saved somewhere. This involves PDFSharp, as I need to take pages out of existing .pdf files and include them in the new file - no biggie. I have a VB6 application that instantiates this COM object and supplies the data to be included in the new .pdf - here too, no biggie.
The thing Im having trouble with is the freeing up of resources, namely the PDF file that is created by PDFSharp:
newDoc.Save(newFile);
newDoc.Dispose();
In VB6, I cannot delete the file or overwrite, though I can still read from it (neither can I delete/rename in the explorer). I dont have this problem in my test .netFrmwk application. The .pdf file is bound during first debug and is not freed after ending debug - I have to close VB6 in order to lift the lock on the file. This tells me that VB6 is holding the resource indefinately, even though theoretically the VB6 COM object is NULLed and PDFSharp has disposed of it.
this is my VB6 code:
Dim path As String
Dim file As String
path = txtPath.Text
file = txtFile.Text
Dim tst As New ComDLL.Class
'Set tst = New ComDLL.Class
Dim i As Long
i = tst.GeneratePDF(path, file)
txt_OUT.Text = tst.GetErrorMessage
Set tst = Nothing
nothing special here either ...
So whats going wrong here?
EDIT: To shed a bit of light on my COM component: I have a class with two methods, as can be seen in the above VB6 code. I did not see it fit to implement a Destructor, as I get rid of all memory references in those methods - so there is nothing to get rid of, really. Was this stupid of me? Admittedly, Ive only been diving into COM for 2 weeks now...