我試圖從vb.net獲得一個DllExport給非託管C++工作。Robert Giesecke的非託管導出
我在使用Robert Giesecke's Unmanaged Exports與Visual Studio 2012並試圖遵循此very helpful hints。我在。* .cpp和* .h文件所在的目錄中通過post build動作從.Net項目複製dll。
我檢查了我的DLL與dumpbin /EXPORTS Nugget.Discovery.dll
,它告訴我,有出口:
File Type: DLL
Section contains the following exports for \Nugget.Discovery.dll
00000000 characteristics
52554A05 time date stamp Wed Oct 09 14:20:21 2013
0.00 version
0 ordinal base
2 number of functions
2 number of names
ordinal hint RVA name
0 0 0000532E StartAnnouncing
1 1 0000533E StopAnnouncing
Summary
2000 .reloc
4000 .rsrc
2000 .sdata
4000 .text
但是,如果我嘗試使用
#import "Nugget.Discovery.dll"
void StartAnnouncing(int serial);
它導入cpp文件,我得到一個智能感知錯誤並嘗試編譯後出現一個錯誤:
IntelliSense: cannot open source file "Debug/Nugget.Discovery.tlh"
error C1083: Cannot open type library file: 'nugget.discovery.dll': Fehler beim Laden der Typbibliothek/DLL.
任何想法我做錯了什麼?
此致敬禮! 斯特凡
你對此非常不利。 #import指令旨在導入COM組件的類型庫。 Giesecke hack不會生成COM組件,它會生成只包含導出函數的普通DLL。您必須在您的C++代碼中使用LoadLibrary和GetProcAddress才能使用它。實際上在C#中創建COM組件非常簡單,只需使用[ComVisible]屬性即可。然而,在C++中使用COM組件有一條學習曲線,你很可能從那個底部開始。 –