簡體   English   中英

DllExport沒有創建入口點

[英]DllExport not creating an entry point

我正在嘗試使用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;
        }
    }
}

我究竟做錯了什么?

澄清:

這是Arma 3擴展DLL,它需要一個名稱為“ _RVExtension@12 ”且帶有簽名的入口點:

void __stdcall RVExtension(char *output, int outputSize, const char *function);

編輯:我已經在項目設置中將目標平台指定為x86,沒有運氣。

事實證明[DllExport]屬性完全按預期運行。

我遇到的問題是C#中沒有本地[DllExport]屬性的原因之一[DllExport]的調用者必須加載.net框架,C#dll才能顯示它的入口點。

問題是我用來檢查暴露的入口點的應用程序沒有加載.net框架,因此沒有報告入口點。

這是通過打開VS2013的開發人員命令提示符並運行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。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM