我试图使用Robert的"UnmanagedExports“nuget包创建一个非托管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;
}
}
}我做错了什么?
Clarification:
这是一个Arma 3扩展DLL,它需要一个带有签名的名称为"_RVExtension@12“的入口点:
void __stdcall RVExtension(char *output, int outputSize, const char *function);编辑:我已经指定目标平台为x86在项目设置,没有运气。
发布于 2015-03-04 17:18:51
事实证明,[DllExport]属性完全按照预期工作。
我遇到的问题是为什么在[DllExport]中没有本机C#属性的原因之一-- dll的调用方必须加载.net框架才能使C# dll显示它的入口点。
问题是,我用来检查公开入口点的应用程序没有加载.net框架,因此没有报告入口点。
通过打开VS2013的Developer命令提示符并运行dumpbin /exports "C:\myDllName.dll"来证实这一点,dumpbin /exports "C:\myDllName.dll"返回了以下内容:
Dump of file C:\myDllName.dll
File Type: DLL
Section contains the following exports for \myDllName.dll
00000000 characteristics
54F6EC86 time date stamp Wed Mar 04 11:29:10 2015
0.00 version
0 ordinal base
1 number of functions
1 number of names
ordinal hint RVA name
0 0 000028CE _RVExtension@12
Summary
2000 .reloc
2000 .rsrc
2000 .sdata
2000 .text很明显地显示了暴露的入口点。
这意味着我无法使用这个dll作为我的扩展,因为Arma 3游戏引擎在默认情况下不会加载.net框架,因此无法调用我的C# dll。
https://stackoverflow.com/questions/28842778
复制相似问题