【发布时间】:2015-03-03 22:00:50
【问题描述】:
我正在尝试使用 Robert Giesecke 的“UnmanagedExports”nuget 包创建一个 C# 非托管 DLL,但它似乎没有创建任何入口点。
完整代码在这里:
using System.IO;
using System.Runtime.InteropServices;
using RGiesecke.DllExport;
namespace ImpactHive
{
internal static class Main
{
[DllExport("_RVExtension@12", CallingConvention = CallingConvention.StdCall)]
static void RVExtension(out char output, int outputSize, char function)
{
using (StreamWriter writer = new StreamWriter(@"C:\dll_log.txt"))
{
writer.WriteLine("It works!");
writer.WriteLine(function);
}
output = function;
}
}
}
我做错了什么?
澄清:
这是一个extension DLL for Arma 3,它需要一个名为“_RVExtension@12”的入口点并带有签名:
void __stdcall RVExtension(char *output, int outputSize, const char *function);
编辑:我在项目设置中将目标平台指定为 x86,但没有运气。
【问题讨论】:
-
dumpbin /exports 显示了什么?
-
@HansPassant 忘了提一下,我已经将目标平台设置为 x86 并允许不安全代码,但它仍然不适合我。
-
@pm100,我在什么情况下运行它?我一直在使用nirsoft.net/utils/dll_export_viewer.html 来检查可用的入口点
-
dumpbin 是用于检查二进制文件的 ms 工具 - 在 sdk 中。我猜 nirsoft 也会这样做
-
它做了类似的事情,但是 dumpbin 可以正常工作,而 nirsoft 没有在 .NET DLL 中显示入口点