对 PInvoke 函数“Techstar.TheRemoteECGSystem.FormView!Techstar.TheRemoteECGSystem.FormView.frmCheck::Analyze”的调用导致堆栈不对称。原因可能是托管的 PInvoke 签名与非托管的目标签名不匹配。请检查 PInvoke 签名的调用约定和参数与非托管的目标签名是否匹配。C++里:
extern "C" __declspec(dllexport) bool Analyze(char *path)
C#里:
[DllImport("FileAnalyze.dll",CharSet=CharSet.Ansi)]
public static extern bool Analyze(string path); private void btnOpen_Click(object sender, EventArgs e)
{
if(Analyze(cPath))
MessageBox.Show("Done");
}我看网上说是参数类型不对,怎么改才对
extern "C" __declspec(dllexport) bool Analyze(char *path)
C#里:
[DllImport("FileAnalyze.dll",CharSet=CharSet.Ansi)]
public static extern bool Analyze(string path); private void btnOpen_Click(object sender, EventArgs e)
{
if(Analyze(cPath))
MessageBox.Show("Done");
}我看网上说是参数类型不对,怎么改才对
为[DllImport("winmm.dll", EntryPoint = "sndPlaySoundA", CallingConvention = CallingConvention.Cdecl)]试一下