Hello,
I am attempting to create C# / .NET wrappers for classes and controls developed with Free Pascal / Lazarus. The target platform is Windows CE, .NET Compact Framework 3.5, and the current version of Lazarus.
I've reviewed the documentation at the link shown below.
http://wiki.freepascal.org/Using_Pascal_Libraries_with_.NET_and_MonoMy first attempt was to simply create a form in Lazarus to be shown in the .NET application. What I am finding is that if I use the ShowMessage then everything is ok. But when I attempt to show my custom form the .NET application shuts down. No error message... it just shots down as if you clicked the close button.
Here's the unit from the Lazarus project:
unit ExportedFunctions;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Dialogs, fmKeypad, fmSample;
procedure ShowForm; stdcall;
procedure SimpleMessage; stdcall;
implementation
procedure SimpleMessage; stdcall;
begin
ShowMessage('Yay!');
end;
procedure ShowForm; stdcall;
var
Form: TForm1;
begin
Form := TForm1.Create(nil);
try
Form.Show;
finally
Form.Free;
end;
end;
exports
ShowForm,
SimpleMessage;
end.
Here's the C# wrapper.
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Linq;
using System.Text;
namespace Tester
{
public class BTEK_FPL
{
[DllImport("BTEK_FPL.dll", CallingConvention = CallingConvention.StdCall)]
public static extern void ShowForm();
[DllImport("BTEK_FPL.dll", CallingConvention = CallingConvention.StdCall)]
public static extern void SimpleMessage();
}
}
Any thoughts or ideas as to what I might be doing wrong?
Also, if anyone has experience creating C# wrappers for visual controls I would greatly appreciate some assistance!