2016-10-04 90 views
0

我一直在試圖用C風格的API(導出表)製作C#dll。而我做了這個最簡單的代碼:UnmanagedExport 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的任何工作示例。
有人可以幫助完成這項工作嗎?現在我只想導出一個函數/

回答

2

問題是 - 您不能在項目構建中設置混合平臺。它必須是x64或x86。即使是最新的.NET也能正常工作。