Page 1 of 1

[Issue] ActiveX CreateObject locks dll

PostPosted: Thu Apr 19, 2012 8:23 pm
by anasrallah
Hi all,

I'm using the CreateObject method from a OOBasic macro to call an activeX dll (created using VB6). The functions in the class are called correctly with no problems, but once I'm done with the dll and close the document, the activex dll file stays locked by the soffice.bin process.
I have the openoffice quickstarter running, if I close the document without having the quickstarter running, the dll is getting released.
I'm using unlocker (http://www.emptyloop.com/unlocker/) to determine what process is locking my files.

here is a brief of what I'm experiencing

ActiveX DLL name: testlibrary.dll
Running: openoffice quickstarter

dim testlib
otestlib = CreateObject("testlibrary.testclass")
.......(function calls here)
otestlib = nothing


I close the odt file, run unlocker on testlibrary.dll, It says soffice.bin locking the file.

I would like to release the activeX dll once I'm done with it, otestlib = nothing is not doing the trick


Thanks

Re: ActiveX CreateObject locks dll

PostPosted: Fri Apr 20, 2012 2:56 am
by rudolfo
As far as I can see your problem is the Quickstarter. Why don't you simply run the (un-)installer for OpenOffice and de-activate the Quickstarter? It saves you 10 seconds when you start OOo for the first time. But what are 10 seconds compared to all the troubles it brings?

Really, I would like to see the Quickstarter de-activated by default in the next OOo realease.

If you are not planning to deploy your macro to other computers/users that's surely the way to go. Of course, you can also waste your precious time to figure out what the ActiveX module of OOo is doing and how its garbage collector works. But keep in mind that this part is only running on Win32 Systems, so you can bet that it is not so intensively tested as the other parts of OOo.

Re: ActiveX CreateObject locks dll

PostPosted: Fri Apr 20, 2012 7:30 am
by anasrallah
I need the Quickstarter because 10 seconds is a long time, for my application every second counts. I think the issue will show also if another odt is open.
maybe there is an alternative for CreateObject to create activex instances in basic. or possible another way to dispose an object once done with it.

Thanks

Re: ActiveX CreateObject locks dll

PostPosted: Tue Apr 24, 2012 1:00 am
by anasrallah
guys any idea??
there's got to be a way to remove references from memory.

Re: ActiveX CreateObject locks dll

PostPosted: Tue Apr 24, 2012 9:01 pm
by rudolfo
Well, no ideas from my side, I can only repeat what I've said before:
rudolfo wrote:Of course, you can also waste your precious time to figure out what the ActiveX module of OOo is doing and how its garbage collector works. But keep in mind that this part is only running on Win32 Systems, so you can bet that it is not so intensively tested as the other parts of OOo.

We are only users here, no developers. And for me I would summarize your post as "The garbage collector of OOo Basic is not working as it should do ...", so probably time to report a bug. See [Tutorial] Reporting bugs or suggestions.

Or depending on how intensively you use OpenOffice in your macro you can also use the OLE Automation/COM Interface of OpenOffice to drive it directly from Visual Basic or VBS, so the VB runtime will still do the cleanup of your ActiveX object, which is hopefully successfully tested.

Re: ActiveX CreateObject locks dll

PostPosted: Tue Apr 24, 2012 10:03 pm
by anasrallah
Just create a bug https://issues.apache.org/ooo/show_bug.cgi?id=119281
Thanks Rudolfo for the help

Re: ActiveX CreateObject locks dll

PostPosted: Fri Apr 27, 2012 9:15 pm
by ms777
rudolfo wrote:... Or depending on how intensively you use OpenOffice in your macro you can also use the OLE Automation/COM Interface of OpenOffice to drive it directly from Visual Basic or VBS, so the VB runtime will still do the cleanup of your ActiveX object, which is hopefully successfully tested.


Another workaround would be to stay with OP Basic, and just wrap the CreateObject call into VB calls by MSScriptControl.ScriptControl. Some example below.

If you try that please let us know, if the dll locking persists ...


Good luck,

ms777

Code: Select all   Expand viewCollapse view
function GetOpenIEWindow2(sPath) as Object
  Dim oleService
  Dim VBScript
  Dim scr as string
  oleService = createUnoService("com.sun.star.bridge.OleObjectFactory")
  VBScript= oleService.createInstance("MSScriptControl.ScriptControl")
  VBScript.Language = "VBScript"

  s = ""   
  s = s + "Public oIE" + Chr(10)

  s = s + "SearchText = """ + sPath + """" + Chr(10)
  s = s + "set oShell = CreateObject(""Shell.Application"")" + Chr(10)
  s = s + "set oShellWindows = oShell.Windows" + Chr(10)
  s = s + "if (not oShellWindows is nothing) then" + Chr(10)     
  s = s + " for each o in oShellWindows" + Chr(10)
  s = s + "  if o.Name = ""Microsoft Internet Explorer"" then" + Chr(10)
  s = s + "   if Instr(1, o.LocationUrl, SearchText, 1) > 0 then" + Chr(10)
  s = s + "     set oIE = o" + Chr(10)
  s = s + "     end if" + Chr(10)
  s = s + "    end if" + Chr(10)
  s = s + "  next" + Chr(10)
  s = s + " end if" + Chr(10)

  VBScript.ExecuteStatement(s)
  GetOpenIEWindow2 = VBScript.CodeObject.oIE
End function