OLEObject/Container access from Thread

Hi!

Im having a problem with ActiveX module (MBAXP). When i put code into thread.

If i import activeX object using xojo’s own (Insert–>activeX) i no more cannot use any functions, as passing licese of the DLL causes xojo to always return exception (NIL) or similar.

The only way i have found to be working with this dll is to use the container, adding programID of MBAXP to it, and then accessing it with following code:

[code]dim retu as boolean
Dim modbus As OLEObject
modbus = Window1.OLEContainer1.Content

Dim params(1) As Variant
dim lic as String =“REDACTED, GET YOUR OWN :D”
'dim lic as String="" 'Try out empty string to get free mode popup etc.
params(1)=lic 'parameters always start at position 1, param(0) is not used
retu=modbus.Invoke(“LicenseKey”,params)
if retu=true then
MsgBox(“Licence OK!”)
return true
else
MsgBox(“Licence error!”)
return false
end If[/code]

But if i try something like this (when i have inserted the mbaxp to the project using the insert–>activeX:

[code]
dim retu as boolean
Dim modbus As New MBAXPLib.Mbaxp

modbus = Window1.OLEContainer1.Content

Dim params(1) As Variant
dim lic as String =“REDACTED, GET YOUR OWN :D”
'dim lic as String="" 'Try out empty string to get free mode popup etc.
params(1)=lic 'parameters always start at position 1, param(0) is not used
retu=modbus.LicenseKey(lic)
if retu=true then
MsgBox(“Licence OK!”)
return true
else
MsgBox(“Licence error!”)
return false
end If[/code]

It just gives out nil exceptions no matter how i try to give it the “lic” string… Not even the freemode work.

Anyone really playing around with the ActiveX here? Or maybe this MBAXP library even? Any help appreciated! :slight_smile:

What happen if you write:

dim retu as boolean
Dim modbus As New MBAXPLib.Mbaxp (Window1.OLEContainer1.Content, True)  //See http://documentation.xojo.com/index.php/OLEObject

Dim params(1) As Variant
dim lic as String ="REDACTED, GET YOUR OWN :D"
'dim lic as String="" 'Try out empty string to get free mode popup etc.
params(1)=lic 'parameters always start at position 1, param(0) is not used
retu=modbus.LicenseKey(lic)
if retu=true then
  MsgBox("Licence OK!")
  return true
else
  MsgBox("Licence error!")
  return false
end If

Exception err As OLEException
  MsgBox(err.Message)