vs2008调用这个C++Builder写的Dll中的函数还是完全正常!
据说是WPF的消息机制导致的问题,不知道各位大咖有和解决之道!?
[DllImport("ZetaEncryption.dll", EntryPoint = "VerifySoftSN", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall, SetLastError = true,ThrowOnUnmappableChar=true) ]
static extern bool VerifySoftSN(string MacCode, string sn, string crc, string pubKey);
2010中调用:
public static bool ZetaVerifySoftSN(string MacCode, string sn, string crc)
{
int imcLen = 0, isnLen = 0;
imcLen = MacCode.Length;
isnLen = sn.Length;
bool bRet = true;
try
{
////////运行到下面这一句会导致
bRet = VerifySoftSN(MacCode, sn, crc, PUBKEY);
// Thread thread = new Thread(() => { bRet = VerifySoftSN(MacCode, sn, crc, PUBKEY); });
// thread.Start();
// Thread.Sleep(1000);
}
catch (Exception e1)
{
bRet = false;
}
return bRet;
}
每次只要运行到VerifySoftSN 这个函数就象进入了黑洞,程序就不动了,过一段时间后会弹出说 堆栈溢出
因为这个dll文件我在C++Builder,Delphi 以及VS2008下使用均为正常,没有任何问题,所以排除是异常处理以及调用规则的问题!
因为现在用c#编写 WPF的应用系统,才出现这种问题,不知道各位有何良策?(在不建议重写的情况下!!!哈哈)