I have a client who wants to talk to some huge accounting software using COM objects in Windows from Xojo. He has been looking into using Xojo for his work for years, but we already tried it several times and had lots of crashes. Some functions simply crash when called. I looked into helping him several times the last two years, but well, didn't see a real reason for those crashes.
Yesterday he called again and asked if I could help. He has a PutValue method for filling data which constantly crashes. GetValue works by the way.
This time I had an idea. To analyze the functions, I created a dummy Visual C project and used #import line. The build the project and Visual Studio creates the C++ includes for this type library. In C++ the function looks like this:
HRESULT PutValue (BSTR FieldName, VARIANT Value, VARIANT * RetVal );
As you see the function takes one string, a variant and a byref variant for the result. Now Xojo creates this delegate:
Delegate Function PutValue_Func3(this As Ptr, FieldName_Param As Ptr, Value_Param As Ptr, RetVal_Param As Ptr) As Integer
And there is the mistake. The variant needs to be passed by Value, not by Reference. This causes crashes as stack contains not enough data 4 bytes for the pointer instead of 16 bytes of the variant structure.
more in feedback case 34221.
I also found case 7195, so this problem could be there for over 5 years. So I now hope that Xojo engineers can find and fix this bug, so my client can enjoy using Xojo to write the apps instead of Delphi.