"Christopher J. Demers" <
[hidden email]> wrote in
message news:a4c099$1cijso$
[hidden email]...
> I have an ActiveX library I am trying to use, but I have a method giving
me
> an "HRESULT Error: Type mismatch. (FACILITY_DISPATCH)" error.
>
> The method Dolphin generated is:
> ===========
> loadJob: bstrJobPath
> "Answer the <VARIANT_BOOL> result of invoking the COM Object's LoadJob()
> method."
>
> ^(self invokeId: 1 with: bstrJobPath)
> ===========
>
> The documentation shows the definition as:
>
> boolean LoadJob(BSTR* bstrJobPath);
>
> I have passed bstrJobPath as a string, and even as a BSTR. Does anyone
> have
> any wisdom they can share with me regarding this? This works from VBA in
> Excel. Any ideas?
For some reason the parameter is passed by ref. (as a BSTR*), not a BSTR.
This will cause a problem if you invoke it passing a string if calling via
IDispatch, since the default conversion of a String/BSTR to a VARIANT will
construct a VT_BSTR, not a VT_BSTR|VT_BYREF. Try instead:
bstrJobPath := aString asBSTR.
var := VARIANT new.
var ulVal: bstrJobPath basicYourAddress.
obj loadJob: var.
Pass-by-ref should really only be used for [out] and [in-out] parameters
(i.e. where the method may want to pass back data by overwriting the
pointer), so if this parameter is really [in] only, which looks likely, I
suggest modifying the generated #loadJob: method to incorporate the above
set-up of the variant to be passed to #invokeId:with:.
Regards
Blair