我试图调用一个方法上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