because regular C functions work differently than the Windows API functions; their "calling conventions" are different, meaning how they pass around parameters is different. (This was hinted at in the error.)

所以请在C#中 使用CallingConvention = CallingConvention.Cdecl),代码如下:

[DllImport("CommonNativeLib.dll", CallingConvention = CallingConvention.Cdecl)]

或者 在C++中:
extern "C" __declspec(dllexport) int __stdcall Add(int a, int b) ...
 

Managed Debugging Assistant 'PInvokeStackImbalance' has detected a problem in 解决方案的更多相关文章

  1. CentOS7- ABRT has detected 1 problem(s). For more info run: abrt-cli list --since 1548988705

    CentOS7重启后,xshell连接,后出现ABRT has detected 1 problem(s). For more info run: abrt-cli list --since 1548 ...

  2. 【Linux】ABRT has detected 1 problem(s). For more info run: abrt-cli list --since 1548988705

    ------------------------------------------------------------------------------------------------- | ...

  3. 安装新版xampp后apache无法启动提示:Apache Service detected with wrong path解决方案

    我以前安装过xampp,因为学习thingPHP需要升级PHP5.0以上,所以我就卸掉了xampp,从新安装新版本的xampp其中PHP是最新版的,但是安装后启动xampp提示如下:Apache Se ...

  4. .net 4中的pInvokeStackImbalance MDA默认是开启的

    今天把我之前发的一个小工具FreeEverything(基于everything的一个简易磁盘清理工具)升级到了.net framework 4.5,并且去掉了对mvvmlight的依赖.结果在测试运 ...

  5. 托管调试助手 "PInvokeStackImbalance":的调用导致堆栈不对称。原因可能是托管的 PInvoke 签名与非托管的目标签名不匹配。请检查 PInvoke 签名的调用约定和参数与非托管

    在C#中一定要检查引用时的数据类型 WinAPI 的数据类型 默认是32位的,但是引用时外部的是 Long类型默认是64位的.所以引用时需要将 long 改为 int 型. 参照 http://blo ...

  6. c#调用c++ dll(二)

    当对c++几种调用方式有了解以后我们可以试着写个c++动态连接库了,我们现在来写个简单的c++求和函数并把它封装成dll,供以后的c#调用 我们写dll的时候,个人认为,要写就要把dll写好,写标准, ...

  7. 对 PInvoke 函数“WinVideo!WinVideo.webcam::SendMessage”的调用导致堆栈不对称

    从.NET1.1升级到.NET2.0时出现的PInvokeStackImbalance错误微软官方的解释 (http://msdn2.microsoft.com/zh-cn/library/0htdy ...

  8. C#,NPOI,Export Generic T Data

    1.Nuget 下载NPOI; Install-package NPOI -version 2.4.1 2.下载EF install-package entityframework -version ...

  9. C++/C#互调步骤

    一.C#调用C++ dll步骤(只能导出方法):  * 1. c++建立空项目->源文件文件夹中添加cpp文件和函数  * 2. c++属性设置中,配置类型设置为动态库dll,公共语言运行时支持 ...

随机推荐

  1. python获取文件

    第一种:使用os.walk: # -*- coding: utf-8 -*- import os def Test1(rootDir): list_dirs = os.walk(rootDir) fo ...

  2. [CSAcademy]Cycle Tree

    [CSAcademy]Cycle Tree 题目大意: 定义环树是一张无向连通的简单图,它的生成方式如下: \(2\)个点\(1\)条边的图是环树: 对任意一个环树,加入\(k\)个点\(a_{1\s ...

  3. OpenGL 模型视图投影矩阵 仿射矩阵

    矩阵基础知识 要对矩阵进行运算,必须先要了解矩阵的计算公式,这个知识的内容涉及到了线性代数. 我们知道在Cocos2dx中,有关于平移,旋转,缩放等等操作,都必须要进行矩阵的乘法. 只需要一张图就能理 ...

  4. Codeforces Round #283 (Div. 2) C. Removing Columns 暴力

    C. Removing Columns time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  5. 模拟拖拽图片 碰撞检测 DOM 鼠标事件 闭包

    <!doctype html><html lang="en"> <head> <meta charset="UTF-8" ...

  6. ThinkPHP使用纯真IP获取物理地址时中文乱码问题

    今天在用ThinkPHP通过纯真IP获取地址时,发现输出结果中文乱码,如图: 经查发现ThinkPHP的IpLocation.class.php类文件中说明:“由于使用UTF8编码 如果使用纯真IP地 ...

  7. POJ 1470 Closest Common Ancestors (LCA,离线Tarjan算法)

    Closest Common Ancestors Time Limit: 2000MS   Memory Limit: 10000K Total Submissions: 13372   Accept ...

  8. both, either, neither的用法

    http://www.yywords.com/Article/200806/347.html  1. 这三个词都用来谈论两者:both 意为“(两者)都”,either意为“(两者中)任意一个”,ne ...

  9. sunstudio 12.3 on solaris 10

    #include <stdio.h> #include <stdlib.h> #define RPT 10000000 int main() { int i=1; for( i ...

  10. spring源码分析之BeanfFactory

    spring的IOC容器能够帮我们自动new对象,对象交给spring管之后我们不用自己手动去new对象了.那么它的原理是什么呢?是怎么实现的呢?下面我来简单的模拟一下spring的机制,相信看完之后 ...