I'm writing a DLL using C# which will be accessed from a Delphi windows app, and have hit the issue re exporting the classes/methods. No matter what I try nothing appears to be getting exported.
I've created a test DLL using the documented method presented by Hans Passant in this question re UnmangedExports.
I've created a C# class library project with the following code:
namespace ExportTestCS
{
public class ExpTest
{
public static void Test()
{
Console.WriteLine("Hi!");
}
}
}
and a C++ 'wrapper' to do the export:
extern "C" __declspec(dllexport)
void __stdcall Test()
{
ExportTestCS::ExpTest::Test();
}
The C++ project references the C# project and it all builds OK, but when I run dumpbin /exports on the DLL there is nothing exported:
dumpbin /exports C:\Temp\ExportTest\ExportTestCS\Release\ExportTest.dll
Dump of file C:\Temp\ExportTest\ExportTestCS\Release\ExportTest.dll
File Type: DLL
Summary
2000 .reloc
2000 .rsrc
2000 .text
C:\Program Files (x86)\Microsoft Visual Studio 14.0>
I've run dumpbin against all the dll's produced by the build for both debug and release and they all give the same result.
My question therefore is - what am I doing wrong? I've spent ages trawling round similar questions but they all seem to be resolved using the C++ wrapper or UnmangedExports.
Both projects are building for x86/win32 and have the same target framework (4.5.2). I've tried various combinations of static classes, no classes, __clrcall/__stdcall etc., etc. but to no avail.
I also previously tried the UnmanagedExports NuGet package without success (that's how I found Hans' answer).
Thanks in advance for any help!
Following all the comments (thanks!) I've confirmed that it's a dynamic library project and I've created a new folder in the C++ project and set that as the output folder. The build now puts the .lib, .exp, .pdb, .dll and .dll.metagen files into that folder, and that is the reported folder in the output tab when building. But still no joy, the output from dumpbin is the same as ever!!
When I run dumpbin against the .lib file in the new output folder I get this:
Dump of file C:\Temp\ExportTest\ExportTestCPP\ExportTest\Output\exporttest.lib
File Type: LIBRARY
Exports
ordinal name
_Test@0
Summary
CC .debug$S
14 .idata$2
14 .idata$3
4 .idata$4
4 .idata$5
10 .idata$6
C:\Program Files (x86)\Microsoft Visual Studio 14.0>
So it looks like the .lib is exporting the Test method but it is not in the final DLL?