How to fix this unmanaged export problem using Delphi / C #

I met unmanaged exports in this anwser on SO.

  • I can control myself to have the simplest project working on SharpDevelop , although I don't have a good C # team.
  • I want to use the excellent Gavaghan.Geodesy library (.Net / C #) written by Mike Gavagan.
  • I want to avoid interoperability using COM.
  • I definitely use Delphi. I just want to use the library with her.

I managed to create the following code:

using System; using System.Collections.Generic; using System.Text; using RGiesecke.DllExport; namespace DelphiNET { internal static class UnmanagedExports { [DllExport("add", CallingConvention = System.Runtime.InteropServices.CallingConvention.StdCall)] public static int add(int left, int right) { return left + right; } } } 

I explored it with Delphi, but was in vain.

I checked the output dll with a PE editor, but it did not have any export data.

I'm going to miss something, and I'm confused.

Edit:

Please - Help me solve the problem.

+1
source share
1 answer

I managed to get this to work as follows:

  • Download the C # template project. This requires Visual Studio, but you must be aware of the Express version.
  • Create a new project based on the template.
  • Create this project.
  • Load the DLL into Dependency Walker to make sure that it actually exports the function. I managed to call a function from Delphi.

Please note that the path to look for the bin\Debug\x86 DLL. There is a DLL in bin\Debug , but this one has no export. Perhaps this is what you were looking for.

+1
source

Source: https://habr.com/ru/post/1344505/


All Articles