我的INTEROP片段有什么问题? - c#

这怎么了我似乎无法弄清楚如何更改它。请帮忙....!!!!
这是错误消息:
调用PInvoke函数'MyClassName :: Process'已使堆栈不平衡。这可能是因为托管PInvoke签名与非托管目标签名不匹配。检查PInvoke签名的调用约定和参数是否与目标非托管签名匹配。


#include "stdafx.h"
#include "TestDll.h"
extern "C" __declspec(dllexport) void Process(lpUnmagedStruct lpStruct, int size)
{
lpStruct[0].a = 0;
lpStruct[0].b = 0;
lpStruct[1].a = 1;
lpStruct[1].b = 1;
}
typedef struct
{
double a;
double b;
}UnmanagedStruct, far *lpUnmagedStruct;

extern "C" __declspec(dllexport) void Process(lpUnmagedStruct lpStruct, int size);

这是我的.NET代码:


[DllImport("TestDLL.dll", EntryPoint = "Process", CharSet = CharSet.Ansi)]
internal static extern void Process([In, Out] ManagedStruct[] aStruct, int size );

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public class ManagedStruct
{
public double a;
public double b;
}

const int size = 3;
ManagedStruct[] aStruct = new ManagedStruct[size];
Process(aStruct, size);

c#参考方案

我怀疑您需要添加调用约定:

[DllImport("TestDLL.dll", 
       EntryPoint = "Process", 
       CharSet = CharSet.Ansi, 
       CallingConvention=CallingConvention.Cdecl)]

当回复有时是一个对象有时是一个数组时,如何在使用改造时解析JSON回复? - java

我正在使用Retrofit来获取JSON答复。这是我实施的一部分-@GET("/api/report/list") Observable<Bills> listBill(@Query("employee_id") String employeeID); 而条例草案类是-public static class…

Mongo汇总 - javascript

我的收藏中有以下文件{ "_id": ObjectId("54490b8104f7142f22ecc97f"), "title": "Sample1", "slug": "samplenews", "cat": …

jQuery DataTable TableTool在IE和Firefox中不起作用 - c#

我在MVC4 ASP.NET Web应用程序中使用Jquery DataTable TableTool。导出到Excel和PDF可以与Chrome完美配合。但是不能在IE和FireFox中使用。我的代码如下 dom: 'T<"clear">lfrtip', tableTools: { "sSwfP…

提交表单后显示模式对话框 - php

提交下载文件后,我有一张表格。我要自动而不是自动下载文件..以显示模态对话框并显示下载链接。<form name="softwareform" id="softwareform" action="../downloadlink.php" method="POST" alig…

如何使用JavaScript乘以文本框值? - c#

<asp:GridView ID="GVFeedType" runat="server" Style="margin-bottom: 6px" BorderColor="#BDBDBD" CssClass="center" Width="500…