Quantcast
Channel: CodeGuru Forums - Visual C++ Programming
Viewing all articles
Browse latest Browse all 3046

Crash via COM method call

$
0
0
Hello everyone!
I will appreciate for help. Faced with strange behavior in the COM module.

I have the structure defined in the idl file
Code:

typedef struct MEDICAMENT_TYPE
        {
                BSTR bstrId;
                long lIdType;
                long lPosSize;
                POSOLOGY arrPos[ARRAY_SIZE];
                BSTR bstrRoa;
                BSTR bstrTkgRsn;
                BSTR bstrUnit;
                BSTR bstrAppInstr;
                BSTR bstrPrscbBy;
                long lAutoMed;
                long lRep;
                long lSubs;
                double dNbPack;
                long lPrivateFieldsSize;
                PRIVATE_FIELD arrPrivateFields[PRIVATE_FIELD_ARRAY_SIZE];
        } MEDICAMENT;

Also, I have a class where I define a method which works with this structure:
IDL file:
Code:

[id(16)] HRESULT AddDrug([in]struct MEDICAMENT_TYPE** medicament, [in]VARIANT_BOOL isDeletePrevDrugs, [out, retval]VARIANT_BOOL* pbStatus);
h file:
Code:

STDMETHOD(AddDrug)(/*[in]*/struct MEDICAMENT_TYPE** medicament, /*[in]*/VARIANT_BOOL isDeletePrevDrugs, /*[out, retval]*/VARIANT_BOOL* pbStatus);
When I debug it into the original project, it all works perfectly. But, in other projects, where I import my COM library, I always get a crash via to function call. (function doesn't do anything, crash in call command)

I know about specific in memory sharing in COM. So, I tried to use the object with CoTaskMemAlloc. I used CoTaskMemAlloc on the client side, used it in the COM Library, and returned it to a client where filled with the necessary data, but nothing helped.

Do you have any idea, where is my mistake?

Thank you in advance!

Viewing all articles
Browse latest Browse all 3046

Trending Articles