exporting function from betterc to windows dll

Abby loniro7678 at twit-mail.com
Sat Mar 14 20:53:45 UTC 2020


I would like to export some functions from my bettec dll for 
dotnet core application in windows.

Right now I have compiled dll using dmd v2.091.0-dirty simply by 
´dub build´

this is the function I have

extern(C) char* test_echo(const(char)* line, size_t len,  ref 
size_t resLen)
{
     enum format = "{\"message\": \"%s\"}\n";

     auto response = cast(char*)malloc(format.length + len);
     resLen = sprintf(response, format, line);
     return response;
}

and this is my dotnet core equivalent

[DllImport(DllName, CallingConvention = 
CallingConvention.StdCall)]
static extern IntPtr 
test_echo([MarshalAs(UnmanagedType.LPStr)]string line, ulong len, 
out ulong resLen);

This works for me in linux but does not in windows, any idea what 
I'm doing wrong?

This is the output from dotnet core

Unhandled exception. System.EntryPointNotFoundException: Unable 
to find an entry point named 'test_echo' in DLL 'test.dll'


More information about the Digitalmars-d-learn mailing list