Using Delphi Assemblies in C#

The process for using Delphi-written assemblies from any other .NET language is remarkably similar to using them from Delphi; just add the references to the project and access the namespaces directly. Listing 6.7 illustrates how our assembly examples could be called from C#.

Listing 6.7. Using a Delphi Assembly from C#c
1:   using System;
2:
3:   namespace DelAsmUser
4:   {
5:       /// <summary>
6:       /// Summary description for Class.
7:       /// </summary>
8:       class Class
9:       {
10:          /// <summary>
11:          /// The main entry point for the application.
12:          /// </summary>
13:          [STAThread]
14:          static void Main(string[] args)
15:          {
16:              new D8DG.LibU.TSomeClass();
17:              D8DG.PkgUnit.Unit.IAmProcedural();
18:          }
19:      }
20:   }

Listing 6.7 can be compiled ...

Get Delphi for .NET Developer’s Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.