.Net Core for Delphi/Lazarus (dotNetCore4Delphi)
------------------------------------------------
The dotNetCore4Delphi is a .Net Core Runtime Library for Delphi which helps Delphi/Lazarus developers work with .Net Core. It is designed to provide a way to interact with .Net Core applications from Delphi/Lazarus.
The easiest and the most efficient Delphi/Lazarus and .NET Core integration technology in the market. Our product helps software companies to integrate Delphi/Lazarus and .NET Core with the highest performance, reliability and flexibility to build the cross-technology web, desktop or server applications. It is also the best native Delphi/Lazarus and .NET Core bridge on the market.
The dotNetCore4Delphi is a new product in the .Net for Delphi family which is a cross-platform framework that runs on Windows, Linux(very soon) and macOS(soon) operating systems. It can be used in different types of Delphi/Lazarus applications such as mobile, desktop, web, cloud, IoT, machine learning, microservices, game, etc. dotNetCore4Delphi product is a lightweight, fast, and cross-platform Framework for Delphi/Lazarus.
Why dotNetCore4Delphi?
----------------------
There are some limitations with the .Net Runtime Library for Delphi. For example, it only runs on the Windows platform because it is somehow tired to Component Object Model(COM) technology and this technology is window specific which makes it difficult for the .Net Runtime Library for Delphi to run on cross-platform.
Today, it's common to have an application that runs across devices; a backend on the web server, admin front-end on windows desktop, web, and mobile apps for consumers. So, there is a need for a single framework for Delphi/Lazarus that works everywhere. The main objective of dotNetCore4Delphi is to make .NET for Delphi a cross-platform compatible that can be used in a wide variety of verticals, from the data center to touch-based devices.
What dotNetCore4Delphi can do:
------------------------------
- Access .Net Core Framework Class Library (such as Collections, IO, Networking, Security, Cryptography etc).
- Access 3rd Party .Net Core Libraries.
- Hosts the .Net Core Common Language Runtime (CoreCLR) in Delphi/Lazarus.
- Can load and access assemblies/types from 3rd party .Net Core libraries or executable files.
- Can invoke members of a .Net Core types (such as constructor, fields, properties, methods and events).
- Can create instance of .Net Core object.
- Can handle .Net Core exceptions.
- Can handle, access and invoke .Net Core events.
- ...and many more.
Competitive Advantages
----------------------
- Cross-platform framework that runs on Windows, Linux(very soon) and macOS(soon) operating systems.
- Full access to .Net Core Framework Class Library.
- No extra dll is required when deployed.
- There is no configuration required and no external tools installation needed. Project can be moved shared across developer and build & test machines with just granting access to source code and transitioned to production within the main application archive.
- Allows Delphi/Lazarus to consume .Net Core libraries as if they were native code.
- When it comes to advanced libraries which use complex objects as method arguments, results, utilize event, callbacks and asynchronous invocation many alternatives become unacceptable whereas dotNetCore4Delphi starts to shine with intuitive and easy way of working with such objects almost like using single technology stack.
- Lightweight and easy to use.
dotNetCore4Delphi Consists of:
1. .Net Core Host (CoreCLR) Library
-----------------------------------
This Library contains Delphi classes and interfaces for starting and hosting the CORE Common Language Runtime which is the .NET execution engine in .NET Core, performing functions such as garbage collection and compilation to machine code. The .NET execution engine in .NET Core is loaded and started automatically by this library making it possible for any application written in Delphi or Lazarus to access the types in the CoreFx(which shares a subset of .NET Framework APIs but comes with its own APIs that are not part of the .NET Framework) or access all the types in any external .Net Core library without prior registrations of the .net Library.
2. .Net Core Framework(CoreFx) Library
--------------------------------------
The Library consist of namespaces which contains Delphi/Lazarus class wrappers of the .NET Core Framework API that are tightly integrated with the .Net Core Host Library. This package enables the Delphi/Lazarus developers to accomplish a range of common programming tasks, including tasks such as string management, data collection, data access, database connectivity, cryptography, network communications, file access and many more. In addition to these common tasks, the library also includes classes that support a variety of specialized development scenarios. It also contains classes that provide access to system functionality.
3. dotNetCore4Delphi Importer
-----------------------------
The dotNetCore4Delphi Importer is a graphical User Interface which is used for importing .Net Core Assemblies such as dll or exe files and generates Delphi class files from the .Net types of the imported assemblies.
Example: How to Load .Net Core Assemblies
=========================================
program Project2;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils,
CNCoreClrLib.Intf,
CNCoreClrLib.AssemblyMgr;
const
DONET_CORE_VER = '5.0.2';
SYSTEM_DATA_COMMON_DLL = 'C:\Program Files (x86)\dotnet\shared\Microsoft.NETCore.App\'+DONET_CORE_VER+'\System.Data.Common.dll';
SYSTEM_NET_SECURITY_DLL = 'C:\Program Files (x86)\dotnet\shared\Microsoft.NETCore.App\'+DONET_CORE_VER+'\System.Net.Security.dll';
SYSTEM_DATA_COMMON_ASSEMBLY_STRING = 'System.Data.Common, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a';
SYSTEM_PRIVATE_DLL = 'C:\Program Files (x86)\dotnet\shared\Microsoft.NETCore.App\'+DONET_CORE_VER+'\System.Private.CoreLib.dll';
SYSTEM_RUNTIME_ASSEMBLY_STRING = 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a';
procedure DisplayAssemblyTypes(AAssembly : ICoreClrAssembly);
var
I: Integer;
m_types: TArray<ICoreClrType>;
begin
Writeln('Loading Types for Assembly ''{0}''', AAssembly.FullName);
Writeln('-----------------------------------------------------');
m_types := AAssembly.GetTypes;
// Display all the types contained in the specified assembly.
for I := 0 to Length(m_types) - 1 do
Writeln(m_types[I].Name);
Writeln('');
Writeln('');
end;
procedure LoadAssemblyFromFile;
var
m_assembly: ICoreClrAssembly;
begin
Writeln('Loading System.Data.Common.dll using Assembly File');
m_assembly := TCoreClrAssembly.LoadFrom(SYSTEM_DATA_COMMON_DLL);
DisplayAssemblyTypes(m_assembly);
end;
//The following example loads an assembly given its fully qualified name, and
//lists all the types contained in the specified assembly.
procedure LoadAssemblyByAssemblyString;
var
m_assembly: ICoreClrAssembly;
m_types: TArray<ICoreClrType>;
I: Integer;
begin
// You must supply a valid fully qualified assembly name.
m_assembly := TCoreClrAssembly.Load(SYSTEM_DATA_COMMON_ASSEMBLY_STRING);
DisplayAssemblyTypes(m_assembly);
end;
procedure LoadAssemblyByFilePath;
var
m_assembly: ICoreClrAssembly;
begin
Writeln('Loading System.Net.Security.dll using File Path');
m_assembly := TCoreClrAssembly.LoadFile(SYSTEM_NET_SECURITY_DLL);
DisplayAssemblyTypes(m_assembly);
end;
procedure LoadAssemblyError;
var
m_assembly: ICoreClrAssembly;
begin
Writeln('Loading Inaccessible Assembly. This should error.');
TCoreClrAssembly.LoadFile(SYSTEM_PRIVATE_DLL);
end;
begin
try
Writeln(' Hello! Welcome to dotNetCore4Delphi ');
Writeln('=========================================================');
Writeln('This program demonstrate how to Load .Net Core Assemblies');
LoadAssemblyFromFile;
LoadAssemblyByAssemblyString;
LoadAssemblyByFilePath;
LoadAssemblyError;
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
end.