Net4Native Project Home Page

To download, please click here

Project Overview

Net4Native is a free open-source library targetting Borland Delphi 2006 / Turbo Delphi that brings utility classes of the .Net world into the native Win32 world.

The first design goal of the library is source code compatibility between .Net and Win32. As an example, consider the following code snippet:

  StartTime: DateTime;
  EndTime: DateTime;
  TimeNeeded: TimeSpan;
  StartTime := DateTime.Now;

  // whatever you want to measure

  EndTime := DateTime.Now;
  TimeNeeded := EndTime-StartTime;


If you have used Delphi.Net you will immediately recognize this code as .Net code. However, with Net4Native you can compile this code against Win32 and get optimized native Win32 code. Did I mention you can use those classes without requiring your users to install the Microsoft .Net Runtime?

Net4Native comes with unit tests that show how to use the classes.

The project is hosted on SourceForge here.

Project Status

The library is considered pre-alpha at the moment as only very few classes/records finished.

100% completed

Partially completed


There were several issues that I came across.

Delphi Bugs

IDE Memory consumption

This is not related to Net4Native but the IDE still has serious memory leaks, even with SP2 applied. Having to close the IDE with 600 MB memory usage is not uncommon.

Memory Leak with record constructors

Net4Native makes heavy use of Records with Methods. Creating a constructor is those Records leaks memory however, as described in QC26450. Net4Native consequently uses the workaround "class function Create" instead of "constructor Create" so this bug will not affect Net4Native.

Missing Operator Overloads (fixed with SP2)

Before SP2, Delphi 2006 had a typo in some operator overloads (has anyone tested those? :)). So be sure to use SP2. QC

Code Completion Bug with Records

The Code Completion (thats the Ctrl+Space thingy) does not know much about Records with Functions. QC

Class Property Bug

When reading Class Properties it is important to always store the result in a temporary variable, otherwise you'll get an internal error. QC

// Wrong:
// Correct:
  CurrentDate := DateTime.Now;

Language deficiencies

Circular record dependencies

Classes can have circular dependencies if they are defined in the same unit using forward definitions. This syntax does not exist for records which makes it impossible for the functions in a record to work with other records that are defined below. There is a QC for this, but it is not even opened.

Records with Interfaces

Records cannot implement interfaces so it's unclear if Net4Native will ever be able to simulate cool things like GetHashCode/ToString in a consistent manner. Maybe some ugly Variant hacks will do the trick, but this will come at the cost of speed and awful code.

Platform differences

Namespace support

Delphi has namespace support on the Win32 world, but can't create a unit that puts its classes into the System namespace, because Delphi has a System unit, too. Because of this, Net4Native is one single unit that is not split into several namespaces.

Gargabe Collection

Delphi Win32 does not have Garbage Collection so Net4Native attempts to provide most of it's functionality through Records with Methods or Interfaces. In some cases this is not possible however, so the library consumer has to apply the usual Create-try-finally-Free-end pattern. As a rule of thumb: If there is a Free function, use it.

Unicode support

Delphi Win32 provides some Unicode support but unfortunately its pretty slow. At the moment only those parts of Net4Native that have to be Unicode use WideString. Everything else is plain old string. In the future, this might all be upgraded to WideString.


The idea for this project was born in December 2005 when I started playing with Delphi 2006's new "Record with functions" features.

A while later I stumbled upon the sister project VBCorLib by Kelly Ethridge who does basically the same for Visual Basic 6. Seeing his project home page motivated me to go public with my sources, too.


If you have any comments, suggestions or just want to tell me that you use this library, feel free to contact me at here.

Known Usages

I use Net4Native in all of my recent projects, like Occam's Tree which is available on Visionary Tools.