我寫的COM類在C#中,和一個函數調用託管代碼是這樣的:需要從託管C++代碼
public void SignAttached(
byte[] message,
ref byte[] signedMessage,
string userName = "USER"
)
}
當我嘗試從C調用此函數++代碼,我exeption : - 「秩12536的安全數組已被傳遞給需要秩1.Unknown錯誤0x80131538的陣列的方法」,和第一秩改變每一次,C++代碼:
SAFEARRAY*message = SafeArrayCreateVector(VT_UI1, 0, 1);
SAFEARRAY*signedMessage = SafeArrayCreateVector(VT_UI1, 0, 1);
_bstr_t userName = "USER";
pInstanse ->SignAttached(message,&signedMessage,userName);
和compilator創建包裝我N *的功能.tlh文件:
HRESULT SignAttached (
SAFEARRAY * message,
SAFEARRAY * * signedMessage,
_bstr_t userName);
,如果看到與幫助oleviewer(IDL語言)導出功能* .tlb文件是:
HRESULT SignAttached(
[in] SAFEARRAY(unsigned char) message,
[in, out] SAFEARRAY(unsigned char)* signedMessage,
[in, optional, defaultvalue("USER")] BSTR userName);
任何人可以幫助?
您確定這是您測試的確切代碼嗎?這對我來說很好。你能發佈一個我們可以看看的repro項目嗎? –
真的!!!!請 - 發送給我的項目,這是如此的幫助我! – Alex
我已經在這裏上傳了一個:https://dl.dropboxusercontent.com/u/42400504/MyClassLibrary.zip –