如何使用Delphi / C#解决这个非管理导出问题 [英] How to fix this unmanaged exports trouble using Delphi/C#
本文介绍了如何使用Delphi / C#解决这个非管理导出问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在这个非管理导出技术8013047/744588> anwser SO。
I came across Unmanaged exports technique in this anwser on SO.
- 我可以自己管理最简单的项目,工作在 SharpDevelop ,虽然我没有C#的良好命令。
- 我想使用优秀的 Gavaghan.Geodesy (我想通过COM避免互操作。
- 我绝对使用Delphi。我只想利用图书馆。
- I can manage myself to have simplest project working on SharpDevelop, albeit I don't have a good command of C#.
- I want to use the excellent Gavaghan.Geodesy (.Net/C#) library written by Mike Gavaghan.
- I want to avoid interoperability through COM.
- I definitely use Delphi. I only want to harness the library with it.
我设法构建以下代码:
using System;
using System.Collections.Generic;
using System.Text;
using RGiesecke.DllExport;
namespace DelphiNET
{
internal static class UnmanagedExports
{
[DllExport("add", CallingConvention = System.Runtime.InteropServices.CallingConvention.StdCall)]
public static int add(int left, int right) {
return left + right;
}
}
}
它与Delphi一起是徒劳的。
I probed it with Delphi but was in vain.
我使用PE编辑器检查了输出dll,但实际上根本没有导出数据。
I checked the output dll with a PE editor but It turned out to have no export data at all.
我想念一些东西,我很困惑。
I miss something and I'm confused.
编辑:
请
- 帮我解决问题
Please - Help me fix the trouble
推荐答案
我设法让这样工作:
- 下载C#项目模板。这需要Visual Studio,但您应该使用Express版本。
- 根据模板创建一个新项目。
- 构建该项目。 / li>
- 在Dependency Walker中加载DLL,看看它确实导出了该函数。我成功地从Delphi调用函数。
- Download the C# Project template. This requires Visual Studio but you should be fine with the Express version.
- Create a new project based on the template.
- Build that project.
- Load the DLL in Dependency Walker to see that it does indeed export the function. I succeeded in calling the function from Delphi.
请注意,找到DLL的路径是 bin \ Debug\x86
。 bin \Debug
中有一个DLL,但没有导出。也许这就是你一直在看的。
Note that the path to find the DLL is bin\Debug\x86
. There is a DLL in bin\Debug
but this has no exports. Perhaps that's what you have been looking at.
这篇关于如何使用Delphi / C#解决这个非管理导出问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文