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

Michael Van Canneyt michael at freepascal.org
Fri Jan 10 16:44:37 CET 2014



On Fri, 10 Jan 2014, Sven Barth wrote:

> 
> 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.

The CrossTalk project for Delphi automates this latter task for you. It also imports .NET assemblies.
Maybe we can ask if it would work with FPC.

Michael.



More information about the fpc-pascal mailing list