【发布时间】:2013-08-11 18:10:21
【问题描述】:
我想知道是否有人可以检查我的 c# dllimport 声明中是否有使用 Delphi XE2 编译的 dll。从 ISAPI 包装器 dll 调用此 dll 工作正常,但我没有运气从 c# asp.net 应用程序调用它。
Delphi 过程定义为:
procedure ExecuteService(const RequestJSON :PWideChar; out ResponseJSON :Pointer; out ResponseJSONSize :Integer; out ResponseContent :Pointer; out ResponseContentSize :Integer); stdcall;
而c#声明是:
[DllImport("services.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Unicode)]
public static extern void BIExecuteService(
String requestJSON,
out IntPtr reposnseJSON,
out int reposnseJSONSize,
out IntPtr reposnseContent,
out int reposnseContentSize
);
有时它会起作用,但大多数情况下它会给出 System.AccessViolationException。
我这几天一直在尝试解决这个问题,声明看起来正确吗?
编辑: 附加到 Delphi XE2 中的 IISExpress 进程,错误似乎发生在 clr.dll 中。也许我的图书馆损坏了一些东西,但我不知道如何找出哪里!
谢谢,
AJ
【问题讨论】:
-
函数的调用方式可能存在问题。你没有表现出来。理想情况下,您将同时显示 Delphi 和 C# 调用代码。正如所问的,这个问题很容易回答,而且答案可能对你没有用。这是 XY 问题的经典示例。