Calling .NET libs from Delphi?

Calling .NET libs from Delphi?

Basically, I’d like to call sql generators from .NET System.Data.SqlClient, like it is done here:

http://scriptdb.codeplex.com/SourceControl/latest#ScriptDB/DatabaseScripter.cs

How much bending over backwards is required to to do this?

 

13 thoughts on “Calling .NET libs from Delphi?


  1. Just for completeness


    http://www.managed-vcl.com/


    Honestly the first thing I’d try is to just import the assembly in Delphi. Failing that I’d try exposing the functionality as a COM compatible wrapper and import that.


    Only after failing at both of those would I spend money on one of the third party libraries.


  2. If you need to do this from the IDE, it’s already a CLR host. There used to be some meager documentation on the interfaces they expose for assembly extension writers (more or less mirrors the interfaces exposed for native extensions) but I’m sure one of the many IL “reflector” tools out there would be more thorough.


  3. Lars Fosdal I’ve wrote something simple using RTTI, basically it creates the SQL dynamically and executes on connection, works noicely with pg and sqlite — can’t share code ): — but this requires published properties and attributes on fields and “table” object, however, it can switch db type and see “new tables” and create them all in a few lines of code.


    need a light install? use sqlite, need a hardcore install? install pg, run the app => database and default records created (:


  4. CrossTalk comes with an installer and the eval is really simple to try out. The import utility can show you before “importing” what types it can not handle. If the .net stuff is too convoluted (unmanaged EWS for an example) i usually write the bulk code in VS Express and put some simple interfacing methods that i import and call from Delphi.

Leave a Reply