Schmidt
5/18/2012 12:05:00 AM
Am 18.05.2012 01:14, schrieb Karl E. Peterson:
> One thing I've wanted to try, but haven't found time to mess
> with yet, would be using an out-of-process ActiveX server,
> rather than an in-process one. In theory, that ought to
> work, and would probably be far more robust than using
> your own middleman EXE.
From my experience this *does* work reliably - though
somewhat slower, due to the marshaling-overhead -
and at the cost of registering an (albeit small)
additional ActiveX-Exe in the usual way for such Binaries.
So, such an ActiveX-Exe-Wrapper needs only to define
a single Public-Class, which then acts as an
*instantiation*-helper for the wrapped (32Bit) COM-Dlls.
For example there are some (Excel-)Users of my
SQLite-Wrapper-Classes, which are implemented in
a VB6-compiled 32Bit COM-Dll.
And what worked for them in XL-64 was a simple
ActiveX-Exe-based Instantiation-Class, which was
just handing out an internally (in the AX-Exe)
instantiated cConnection-Class:
'in the AX-Exe Public Class
Public Function GetConnection() as cConnection
Set GetConnection = New cConnection
End Function
The above was all there was to do, since cRecordset
and cCommand-Instances are able to be "derived"
from the already wrapped cConnection-Instance.
e.g. within XL-(64Bit-)VBA then:
Dim Cnn As cConnection
'use the CreateObject-Call against the AX-Exes PublicClass
Set Cnn = CreateObject("AXExeProj.PublicClass").GetConnection
'At this point Cnn holds a 64Bit-*Proxy*-Instance within
'the XL-64Bit Process, which got its Interface-Infos from
'the referenced 32Bit-Dll-Typelib without problems
'
'The real 32Bit-Cnn-Instance runs within the AX-Exe - and
'calls between the 64Bit-Cnn-Proxy and the 32Bit-Cnn-Instance
'are apparently marshaled without any hickups, even when
'one of the participants of this OutOfProcess-mechanism
'differs with regards to the "BitCount".
Cnn.OpenDB DBFileName 'this call is 64Bit-to-32Bit-marshaled already
Dim Rs As cRecordset
Set Rs = Cnn.OpenRecordset("Select Something From SomeTable")
'and the above Rs-retrieving-call works too, because the
'returned Rs-Instance was derived from the already marshaled
'Cnn - and therefore the real Rs-Instance runs within the
'ActiveX-Exe too - on the side of the XL-64Bit-VBA-environment
'there's (once again) only a 64Bit "Rs-Proxy-Object" at work...
Olaf