[fpc-pascal] Load .NET dll (or bootstrap CLR to be precise) from FPC

Sven Barth pascaldragon at googlemail.com
Fri Jan 10 16:35:39 CET 2014


Am 10.01.2014 08:19 schrieb "leledumbo" <leledumbo_cool at yahoo.co.id>:
>
> I'm writing a web app hosting several tasks in FPC, however one of the
task
> is calling a function residing in a .NET dll. I've made a flat C interface
> for the dll (so that I can call it from FPC easily), and it works just
fine
> IF the dll is somehow loaded first. Currently, I use a trick to debug my
web
> app from Visual Studio and makes the app calls the dll function. This
> automatically bootstraps the CLR and as long as there's no update on the
dll
> my app would stay working. However, this is of course cumbersome. I wonder
> if there's any way to load the dll without such a dirty trick.
>

There are basically two possibilities: adjust the .Net assembly to be
hosted as a COM server, generate a TLB and use that to generate a interface
unit for FPC. Please ask Google or the search engine of your choice for the
first two steps.

The other possibility is to host the .Net runtime in your application. For
this you can take a look at these links:
http://www.codeproject.com/Articles/416471/CLR-Hosting-Customizing-the-CLR
http://code.msdn.microsoft.com/windowsdesktop/CppHostCLR-e6581ee0
The CLRCreateInstance function seems to be defined in mscoree.dll, so
you'll need to import that.

I've not done this myself yet, but I hope it helps you.

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20140110/d637ce10/attachment.html>


More information about the fpc-pascal mailing list