Overview
----------------------------------------------
The .Net Runtime Library for Delphi (CNClrLibrary) is the best library to work with .Net framework and .Net libraries from Delphi. It is designed to provide a way to interact with applications written in anyone of the .Net languages (such as C#, Visual Basic.Net, Delphi.Net, JScript.Net, etc) from Delphi.
The .Net Runtime Library for Delphi (CNClrLibrary) allows Delphi to use .Net libraries without the need for registry entries, COM registrations, or changes to the .NET libraries.
Applications built with the .Net Runtime Library for Delphi will not require any dll files when deployed.
CNClrLibrary allows developers to create applications that can mix managed (.NET) and unmanaged ("native" Delphi) code in the same project.
A Brief History of .NET in the World of Delphi
----------------------------------------------
Ever since it was originally announced, the Delphi community has had a love/hate relationship with .NET. Being spoiled by the richness in RAD development they had been enjoying for years, the community was quick to dismiss .NET as something that might bring benefits to MFC or Visual Basic developers, but would bring little benefit over Delphi and its powerful VCL class library and RAD form designers. Many also saw .NET as the latest development fad that would excite people for a while but quickly die out for lack of serious adoption.
Three significant releases later, it has now become obvious that these assumptions were wrong. The .NET 2.0 core framework has introduced significant development advances in the .NET languages, such as Generics that make .NET development attractive and, with the new services branded under 3.0, Microsoft has introduced a significant new paradigm for user interface design that is likely to revolutionize how tomorrow's Windows desktop applications will look and feel. The third party market for .NET has developed strongly, with a vast range of professional components being available in all imaginable areas while at the same time the Delphi component market seems to be winding down, as many third party vendors scale down their support in favor of .NET or are leaving the market altogether.
Embracing .NET with Delphi
----------------------------------------------
This is the situation that triggered the idea for the .Net Runtime Library for Delphi: what if there was a way for Delphi developers to preserve their existing investment in solid, working Win32/Win64 code written in Delphi, but at the same time enable them to extend that codebase, using new .NET-based technologies? What if developers could use .NET Framework Class Libraries and all the other benefits of the .NET framework when writing new code for their applications, while keeping the existing parts of their application code basically untouched without porting and retesting?
CNClrLibrary enables you to keep your investment in your existing native Delphi code base, while at the same time opening your applications to .Net Framework Class Libraries. At the same time, the existing code can be kept and maintained in Delphi, and both parts can contribute to what appears to the end user as a single, unified application. CNClrLibrary makes it possible to employ new and emerging .NET technologies within your existing Delphi-based application frame.
Competitive Advantages
----------------------------------------------
The following are some of the advantages the .Net Runtime Library for Delphi have over it competitors:
- Full access to .Net Framework Class Library (Including new and emerging .NET technologies).
- No extra dll is required when deployed.
- No COM registration of .Net Libraries is required when deployed.
- There are tools to generate your .Net Libraries into Delphi pas files.
- Allows Delphi to consume .Net libraries as if they were native code.
- Easy to use.
CNClrLibrary can do so much:
----------------------------------------------
- Access .Net Framework Class Library (such as Collections, Data Configuration, DataSets, Data Access, Database Connectivity, Diagnostics, IO, Linq, Dynamic Linq, System, Device and Application Management, Networking, Reflections, Security, Encryption, Cryptogrphy, Character Encoding and String Manipulation, XML etc).
- Access Third Party .Net Libraries.
- Access Your .Net Libraries.
- Hosts the .Net Common Language Runtime (CLR) in Delphi.
- Can load and access assemblies and their types from third party .Net libraries or your own .Net libraries or executable files.
- Can load and access assemblies and their types from Global Assembly Cache (GAC)
- Can invoke members of the loaded assembly types which includes constructor, fields, properties, methods and events.
- Can invoke static members of the loaded assembly types which includes constructor, fields, properties, methods and events.
- Can load and access assemblies and their types from Global Assembly Cache (GAC)
- Can create instance of .Net object from the types of the assembly loaded.
- Can handle .Net exceptions.
- Can handle, access and invoke .Net events.
- Can host .Net controls in Delphi VCL Forms.
- Contains a utility for importing .Net libraries(third party or your own .Net libraries) or WSDL and generates Delphi pas files.
- ...and many more.
.Net Runtime Library for Delphi Consists of:
1. Host Class Library
----------------------------------------------
This is also called Delphi Host Class Library or DHCL. This Library contains Delphi classes and interfaces for starting and hosting the .Net Common Language Runtime (CLR) which allows Delphi applications to load and access .net assemblies, create object instance of the types from the loaded assembly, invoke the members of the types etc. The CLR manages memory, thread execution, code execution and other system services.
2. Framework Class Library
----------------------------------------------
The Delphi Framework Class Library (DFCL) is a Delphi interface representation of the .NET Framework class library which is a collection of reusable types that tightly integrate with the Delphi Host Class Library.
Tools and Components
----------------------------------------------
- .Net Assembly/WSDL Importer: This is only available for Professional Edition User License. This tool allows users to import any .Net libraries(3p libraries or your own libraries) or WSDL and generate delphi pas files from the imported libraries which uses the classes and interfaces in the .Net Runtime Library.
- .Net VCL for Delphi:
1. Container VCL Control - This control allows a developer to host .Net controls in Delphi VCL Forms.
2. ADO.Net VCL for Delphi - Allows developers to create fastest and most reliable database connectivity solutions for any database using ADO.Net technology in Delphi.
Example: How to use .Net XML Classes to compare two element names
-----------------------------------------------------------------
program XML;
{$APPTYPE CONSOLE}
{$R *.res}
uses
CNClrLib.Xml,
CNClrLib.Core;
var
NameTable: _NameTable;
Book, Price: Variant;
Settings: _XmlReaderSettings;
Reader: _XmlReader;
ReaderHelper: _XmlReaderHelper;
ObjectHelper: _ObjectHelper;
begin
NameTable := CoNameTable.CreateInstance;
Book := NameTable.Add('Book');
Price := NameTable.Add('Price');
// Create the Reader.
Settings := CoXmlReaderSettings.CreateInstance;
Settings.NameTable := NameTable.AsXmlNameTable;
ReaderHelper := CoXmlReaderHelper.CreateInstance;
Reader := ReaderHelper.Create_1('books.xml', Settings);
Reader.MoveToContent;
Reader.ReadToDescendant('Book');
ObjectHelper := CoObjectHelper.CreateInstance;
if ObjectHelper.ReferenceEquals(Book, Reader.Name) then
begin
// Do additional processing.
end;
end.
Deployment
-----------------------------------------------------------------
- Microsoft .Net Framework (Latest versions of Windows have .Net Framework pre-installed)
- Basic Copy Deployment
- Your application
Feature Matrix
-----------------------------------------------------------------
Delphi and .NET are different platforms. Each has unique features that the other does not. Support exists for all .NET functionalities.
- Arrays
- Simple Types (byte, int, bool, string, etc)
- Object Type
- Exceptions
- Non-Generic Collections
- ArrayList
- Hashtable
- Queue, Stack
- SortedList
- BitArray
- Comparer
- Interface
- LinkedList
- Stack
- etc
- Generic Collections
- List<>
- Dictionary<,>
- HashSet<>
- LinkedList<>
- Stack<>
- etc
- Events
- XML
- Reflections
- .NET Remoting
- Type Conversion
- Formatting Types
- Linq and Dynamic Linq
- IO
- DirectoryServices
- Management
- Networking
- Data
- Security
- Configuration
- Device
- Diagnostics
- Boxing and UnBoxing represented as Wrap and Unwrap methods respectively
- Access to all the .Net Framework Class Libraries except some classes in System.Windows and System.Web
- Dynamic loading of user assemblies
- Constants
- Enumerators
- ADO.Net
- SQL Server data provider
- Interfaces
- Object Arrays (Indexed object properties are supported)
- Classes
- Fields
- Properties
- Methods
- Events
- Constructors/Destructors
- Indexed properties
- Including default indexers
- Namespaces
- Object references
- Arguments
- Return values
- Properties (including assignment)
- Statics
- Fields
- Properties
- Methods
- Events
- Types
- Simple Value types (byte, int, etc)
- Large value types (int64, uint64 etc)
- Decimal / Float types
- Classes
- String
- Structs
- TypeInfo
- Var / out arguments
- x86 / x64 / Any
IDE Compatibility
-----------------------------------------------------------------
The Runtime Library integrates with the following Embarcadero Delphi products:
- Delphi 2009
- Delphi 2010
- Delphi XE
- Delphi XE2
- Delphi XE3
- Delphi XE4
- Delphi XE5
- Delphi XE6
- Delphi XE7
- Delphi XE8
- Delphi 10.0 Seattle
- Delphi 10.1 Berlin
- Delphi 10.2 Tokyo
- Delphi 10.3 Rio
- Delphi 10.4 Sydney
.NET Framework 4.5 Service Pack 1 or higher is required for the Runtime Library.