2

我正在尝试使用(https://www.nuget.org/packages/UnmanagedExports)导出我的一些函数,但它似乎不起作用。

using System;
using System.Collections.Generic;
using System.Text;
using RGiesecke.DllExport;
using System.Runtime.InteropServices;
namespace Verificare
{

    static class Exports
    {
        [DllExport]
        public static void Salut()
        {
        }
    }
}

我正在使用 DLL EXPLORER 查看导出的函数,不幸的是,在我的 dll 中没有导出函数。

4

1 回答 1

2

在这里尝试和验证,它按预期工作:

  • 创建了一个类库项目
  • 从 NuGet 添加了包
  • 将配置更改为 x86

创建了一些功能:

using RGiesecke.DllExport;

namespace ClassLibrary1
{
    public static class Class1
    {
        [DllExport]
        public static int Hello()
        {
            return 1;
        }

        [DllExport]
        public static void Nope()
        {
        }
    }
}

如您所见,函数已正确导出:

在此处输入图像描述

如果有疑问,请使用CFF Explorer检查 DLL ,尝试新项目。

注意:当您创建项目的另一个配置时,输出不在 bin\Debug 中,而是在 bin\x86\Debug 中,请确保您正在检查正确的 DLL。

于 2013-10-23T16:16:23.193 回答