Using Assemblies in Delphi

Using assemblies similar to the ones just shown is a straightforward process. The first step is to add a reference to the assembly in the project by selecting Project, New Reference from the main menu or right-clicking in the Project Manager and selecting Add Reference. After the reference is added, the appropriate namespaces can be added to the uses clause. Listing 6.6 shows a sample project unit that uses both the package and library assemblies created previously. Code from these assemblies is referenced on lines 13 and 14 of the listing.

Listing 6.6. Using Assemblies in Delphi
1: program TestApp; 2: 3: {$APPTYPE CONSOLE} 4: 5: {%DelphiDotNetAssemblyCompiler 'D8DG.TestPkg.dll'} 6: {%DelphiDotNetAssemblyCompiler 'D8DG.TestLib.dll'} ...

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.