1

I used the popular Robert Giesecke template for unmanaged exports in order to create a DLL for usage from native code.

Actually it should be really simple because one only has to adapt the given example function. Building works, but this command doesn't show me any function:

$ dumpbin.exe /exports <mydllname>.dll

My exported function looks like this:

using RGiesecke.DllExport;

namespace HelloWorld
{
   internal static class UnmanagedExports
   {
       [DllExport("_adddays", CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)]
       static double AddDays(double dateValue, int days)
       {
          return System.DateTime.FromOADate(dateValue).AddDays(days).ToOADate(); 
       }
   }
}

Does anyone have an idea what I am doing wrong? I'd be very happy about any help.

FYI: I'm using VS 2012, .NET-Framework 4.5, used class-library project template. I already tried changing the platform target to x86 (recommended in other posts) but didn't help.

LM358
  • 141
  • 9
  • The tool has a strong knack for completely failing to do its job without any diagnostic. You *must* set the Project > Properties > Build tab > Platform target to something else than AnyCPU, pick x86 or x64. Make some sense, it needs to know what flavor of unmanaged code to generate. And I found it necessary to run VS elevated to get it to behave, no real idea why that's necessary. Given the rather poor diagnostic that's produced when the managed code throws an exception, I concluded that it wasn't good enough to use. [Consider this](http://stackoverflow.com/a/17131801/17034). – Hans Passant Aug 26 '16 at 14:11
  • thanks for the answer. But I already set the platform target to x86 and I even started VS as admin (if you mean this by 'elevated'). Both didn't change anything for me. – LM358 Aug 26 '16 at 15:52

0 Answers0