我試圖調用一個方法上ssdeep fuzzy.dll麻煩
具體來說,我試圖調用此方法....
int fuzzy_hash_filename (
const char * filename,
char * result
)
我有以下...
<DllImport("C:\SSDeep\Fuzzy.dll", EntryPoint:="fuzzy_hash_filename")>
Private Shared Function fuzzy_hash_filename(
<InAttribute(),
MarshalAsAttribute(UnmanagedType.LPStr)>
ByVal Filename As String, ByVal Result As StringBuilder) As Integer
End Function
Public Shared Function FuzzyHash(Filename As String) As String
Dim Ret As New StringBuilder
Ret.Capacity = NativeConstants.FUZZY_MAX_RESULT
Dim Success = fuzzy_hash_filename(Filename, Ret)
If Success <> 0 Then
Throw New Exception("SSDeep fuzzy hashing failed")
End If
Return Ret.ToString
End Function
如果我運行此代碼,VS給了我多種形式對話
一個調用的PInvoke函數「(胡說):: fuzzy_hash_filename」有不平衡的堆棧。這很可能是因爲託管的PInvoke簽名與非託管目標籤名不匹配。檢查PInvoke簽名的調用約定和參數是否與目標非託管簽名相匹配。
(FWIW呼叫似乎成功,如果我忽略了警告,所以我必須接近)
做我需要做我的定義中,以這種打算什麼變化?
也許這將幫助:http://social.msdn.microsoft.com/Forums/en -US/csharplanguage/thread/e03c925e-c094-40f1-9fb0-20ac8dc5972d/ – ken2k 2012-08-07 09:13:12