1

As my first time as a student employee programming I have to create a DLL in C#.NET which is callable from Delphi.

I've read about this being not so easy due to Delphi being native code and .NET being managed.

I've also read about 'Unmanaged Exports' from Robert Giesecke. Could this be the solution?

Since I do not have Delphi on my machine (Delphi isn't free), I can't test this out for myself.

Also, will I have problems with my datatypes when I implement the Unmanaged Exports?

Last but not least, is there a language I could use that would have the same problem as Delphi for loading the DLL? It'd be nice for me to be able to test.

John
  • 2,820
  • 3
  • 30
  • 50
Jasper Catthoor
  • 595
  • 1
  • 6
  • 22

3 Answers3

5

UnmanagedExports is one option. It certainly works very well. Other options include:

  • Exposing the functionality using COM.
  • Exposing the functionality via a C++/CLI mixed mode assembly.
  • Hosting the CLR from your Delphi code.

The final option is not very tractable. Don't attempt to do that.

You'll almost certainly encounter problems with interop data types unless you are already an expert in the field.

You can certainly test this out with FreePascal. Very likely you can write code in FreePascal that consumes your .net assembly and later use the exact same code in Delphi. Even if you have to change it somewhat, the lessons you will learn will be exactly the same.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
3

You can make your .Net DLL as Com visible. Check this link.

Delphi can load Com objects without problems. This in theory, I don't have specific code samples, but you can try with different tutorials, they practically explains the same.

I don't know about the data types, but COM always tries to cast to a base type (double, float to decimal, number to integer, and complex objects to dynamic objects).

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
jparaya
  • 1,331
  • 11
  • 15
0

You can use the .Net Runtime Library for Delphi in http://dotnetruntimelibraryfordelphi.sourceforge.net/

The runtime library allows you to host and access .net library types.

Bizzo
  • 1