UnmanagedExport dll不会创建导出表

时间:2016-10-04 20:19:19

标签: c# .net dll

我一直在尝试使用C风格API(导出表)创建一个C#dll。我已经制作了这个最简单的代码:

using System;
using System.Runtime.InteropServices;
using RGiesecke.DllExport;

namespace CS_Post
{
    public class Class1
    {
        [DllExport("ABC", CallingConvention.Cdecl)]
        public void test()
        {
            Console.WriteLine("hehe");
        }
    }
}

当我转储这个dll时,我得到了:

E:\Projects\CS_Post\bin\Release>dumpbin \exports CS_Post.dll
Microsoft (R) COFF/PE Dumper Version 14.00.24213.1
Copyright (C) Microsoft Corporation.  All rights reserved.


Dump of file CS_Post.dll

File Type: DLL

  Summary

        2000 .reloc
        2000 .rsrc
        2000 .text

它也仅适用于.NET 3.5,任何更高版本似乎都找不到ildasm.exe

Microsoft.Build.Utilities.ToolLocationHelper could not find ildasm.exe

我甚至无法找到这个UnamanagedExports的任何工作示例 有人可以帮忙完成这项工作吗?现在我只想导出一个函数/

1 个答案:

答案 0 :(得分:2)

问题是 - 您无法在项目构建中设置混合平台。它必须是x64或x86。即使是最新的.NET也能正常工作。