Recent

Author Topic: Using C# DLL in Lazarus  (Read 3232 times)

JohnRambo

  • Newbie
  • Posts: 4
Using C# DLL in Lazarus
« on: September 20, 2017, 10:31:01 pm »
At first I admit that in C # I am green like chives. I want to prepare a C# DLL using the UnmanagedExports tool (https://www.nuget.org/packages/UnmanagedExports) in the C # DLL. Here's an example by author:https://stackoverflow.com/a/2055508/1919267 . I do it same as this link.
I created DLL and use it in Delphi XE7, everything works fine. But there is a problem: when I want to use the same file in Lazarus, it returns nothing. The code:
Code: Pascal  [Select]
var
  adder : IDotNetAdder;
begin
  try
   CreateDotNetAdder(adder);
   Writeln('4 + 3 = ', adder.Add3(4));
  returns me 0 (so I am thinking that DLL response  is nil). Is there any solution to fix that? Should I need to fix my pascal code or fix that DLL?

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: Using C# DLL in Lazarus
« Reply #1 on: September 21, 2017, 11:09:28 am »
Just several days ago I went a little different path. I used regasm tool from .net framework to register .net assembly as a COM object, which I later imported into Delphi and used. I did not have a need to try the same with Lazarus, but last time I checked COM and ActiveX support have advanced a lot so that should be doable too.
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

 

TinyPortal © 2005-2018