Free Pascal => Windows => Topic started by: JohnRambo on September 20, 2017, 08:16:49 pm
Title: Using C# DLL in Lazarus
Post by: JohnRambo on September 20, 2017, 08:16:49 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 (https://www.nuget.org/packages/UnmanagedExports)) in the C # DLL. Here's an example by author:https://stackoverflow.com/a/2055508/1919267 (https://stackoverflow.com/a/2055508/1919267) . So far ok, managed to produce a DLL and use it in Delphi. But there is a problem: when I want to use the same file in Lazarus, it returns nothing. The code:
after you define the handler and the function you can use it.
Title: Re: Using C# DLL in Lazarus
Post by: JohnRambo on September 21, 2017, 03:30:21 pm
Sorry for double topic but I can't delete topic in wrong category. I cant use COM, because I need to use old version of Lazarus (without ActiveX). In my code I declare procedure in static way:
When I try to do it dynammicaly nothing work, only more problems. I don't understand that Delphi do it perfectly, but Lazarus not. In attachments I put .dll file and my pas unit. I don't asking about do it for me but to show me the way
Title: Re: Using C# DLL in Lazarus
Post by: JohnRambo on September 21, 2017, 04:53:56 pm
OK I made it. :D Firstly we need to get some information: https://stackoverflow.com/a/9353800 "In C#/C++ you will need to define the Result as out Parameter, in order to maintain binary code compatibility of stdcall calling conventions" - thats the key. In my C# code I was use return. For Delphi its ok, but for Lazarus it is problematic. So I retyped my c# code from: