need to call managed code from unmanaged c++ code

Viewed 891

I wrote COM class in C#, and one function like this :

public void SignAttached(
        byte[] message,
        ref byte[] signedMessage, 
        string userName = "USER"
        )

}

when i try to call this function from C++ code i have exeption: - "SafeArray of rank 12536 has been passed to a method expecting an array of rank 1.Unknown error 0x80131538", and first rank changing every time, C++ code:

SAFEARRAY*message = SafeArrayCreateVector(VT_UI1, 0, 1);
    SAFEARRAY*signedMessage = SafeArrayCreateVector(VT_UI1, 0, 1);

    _bstr_t userName = "USER";

    pInstanse ->SignAttached(message,&signedMessage,userName);

and compilator create wrapper in *.tlh file for function:

HRESULT SignAttached (
    SAFEARRAY * message,
    SAFEARRAY * * signedMessage,
    _bstr_t userName );

and if to see into *.tlb file with help oleviewer (IDL language) exporting function is:

    HRESULT SignAttached(
                [in] SAFEARRAY(unsigned char) message, 
                [in, out] SAFEARRAY(unsigned char)* signedMessage, 
                [in, optional, defaultvalue("USER")] BSTR userName);

can anybody help ?

1 Answers
Related