I'm using CreateObject(progId)
in Vb to create a pdfDOcument
.
But the problem is that after i'm done and closing the document and release, How can I shutdown the process?
How can I reference the process and know if it was already open by the user before I created the object? And how can I kill the process if the process was not running before I created the object (pdfDocument
)?
Is there better strategies than to use CreateObject()
?
The solution that we've found is to create the application object before we create any application's object.
For example:
dim objApp as object = CreateObject("AcroExch.App")
dim objDoc as Object = CreateObject("AcroExch.document")
...
objApp.CloseAllDocuments()
System.Runtime.InteropServices.Marshal.ReleaseComObject(objApp)
System.Runtime.InteropServices.Marshal.ReleaseComObject(objDoc)
But next time I will never use CreateObject
.
I'll try to use framework classes (especially the Runtime
and Reflection
for such examples).