Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2011-11

dll for C#

5 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

ik

Hello,

I have a requirement to create an API for application that C# can communicate with using dll (rather then REST). What is required by FPC to be able to create such DLL ?

Thanks,
Ido

ik
to ik
ik wrote 6 lines
Hello, I have a requirement to create an API for application that C# can communicate with using dll (rather then REST). What is required by FPC to be able to create such DLL ?

And one other thing I forgot, it must support classes.

Thanks, Ido
Unknown author
to ik
ik wrote 10 lines
On Mon, Nov 28, 2011 at 10:22, ik wrote: > Hello, > > I have a requirement to create an API for application that C# can > communicate with using dll (rather then REST). What is required by FPC to > be able to create such DLL ? > And one other thing I forgot, it must support classes.

That will simply not be possible. The C# class model is fundamentally different from FPC's. Even the reverse (using C# classes from FPC) is hardly possible (although crosstalk from atozed software does a good effort in Delphi).

Michael.

Elmar Haneke
to ik: And one other thing I forgot, it must support classes.
And one other thing I forgot, it must support classes.

You have to write an procedural wrapper around your class - each method gets an Procedure thar recieves the object as parameter and calls that object's method. These procedures are exported as stdcall as for an regular Windows DLL.

In C# you can write an class storing the FPC object as an IntPtr. The procedures from DLL are called using the P/Invoke mechanism.

Elmar

ik
to Elmar Haneke
Elmar Haneke wrote 12 lines
And one other thing I forgot, it must support classes. > You have to write an procedural wrapper around your class - each method gets an Procedure thar recieves the object as parameter and calls that object's method. These procedures are exported as stdcall as for an regular Windows DLL. In C# you can write an class storing the FPC object as an IntPtr. The procedures from DLL are called using the P/Invoke mechanism.

Thank you, it sounds like a good idea

Show quoted text 7 lines
Elmar ______________________________**_________________ fpc-pascal maillist - http://lists.freepascal.org/**mailman/listinfo/fpc-pascal<http://lists.freepascal.org/mailman/listinfo/fpc-pascal>