本文共 962 字,大约阅读时间需要 3 分钟。
要想在vs2005中实现这样的效果,是没有相应的组件的,我使用的是codeproject上
上的Windows XP style Explorer Bar 将XPExplorerBar.dll添加到工具箱后,在使用时
但是会出现如下错误:
在in visual studio 2005:PInvokeStackImbalance was detectedMessage: A call to PInvoke function 'XPExplorerBar!XPExplorerBar.NativeMethods::LoadBitmap' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.the error is raised in the following line in GetResourceBMP methodIntPtr hBitmap = NativeMethods.LoadBitmap(hModule, Int32.Parse(resourceName));
这是由于winAPI中的long是32位,C#中long是64位,生成可以成功,但是在执行后当然会出现堆栈不平衡的问题,在 vs2003中是捕获不出来的,但是在vs2005中是必须要处理的。
解决方法:
在NativeMethods.cs中将
static extern IntPtr LoadBitmap(IntPtr hInstance, long resourceID)
中的long 换为int再重新生成即可。
我已经生成好.dll 文件并发布到我的资源里。
如有问题大家可以给我发邮件。
下载地址:
参考网站:
从.NET1.1升级到.NET2.0时出现的PInvokeStackImbalance错误