我的项目在.NET Frame 3.5中成功运行且没有错误.但是,当我将它定位到.NET Frame工作4.我得到了错误:
" 对PInvoke函数的调用使堆栈失衡.这可能是因为托管的PInvoke签名与非托管目标签名不匹配. "
我使用了非托管库,如下所示:
[StructLayout(LayoutKind.Sequential )]
public class DGNElemCore
{
public int offset;
public int size;
public int element_id;
public int stype;
public int level;
public int type;
public int complex;
public int deleted;
public int graphic_group;
public int properties;
public int color;
public int weight;
public int style;
public int attr_bytes;
public IntPtr attr_data;
public int raw_bytes;
public IntPtr raw_data;
}
[DllImport("DgnLib.dll", EntryPoint = "DGNOpen")]
public static extern IntPtr DGNOpen(string fileName, int bUpdate)
Run Code Online (Sandbox Code Playgroud)
你知道如何解决这个错误吗?
Ehs*_*san 45
将其与dll导入一起添加.
, CallingConvention = CallingConvention.Cdecl)]
Run Code Online (Sandbox Code Playgroud)
从这里开始.
平台调用
为了提高与非托管代码的互操作性能,平台调用中的错误调用约定现在导致应用程序失败.在以前的版本中,编组层在堆栈中解决了这些错误.
在Microsoft Visual Studio 2010中调试应用程序将提醒您这些错误,以便您可以更正它们.如果您有无法更新的二进制文件,则可以在应用程序的配置文件中包含该元素,以使调用错误能够像早期版本一样在堆栈中解析.但是,这可能会影响应用程序的性能.
| 归档时间: |
|
| 查看次数: |
17595 次 |
| 最近记录: |