CrystalNet 4 Posted September 20, 2019 (edited) The .Net Runtime Library for Delphi 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 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. .Net Runtime Library for Delphi allows developers to create applications that can mix managed (.NET) and unmanaged ("native" Delphi) code in the same project. Competitive Advantages: 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. Full access to .Net Framework Class Library. Easy to use. CNClrLibrary can do so much: Access .Net Framework Class Library. Access Third Party .Net Libraries. Access Your .Net Libraries. etc. Features:- Can 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, Cryptography, Character Encoding and String Manipulation, XML etc). Can access Third Party .Net Libraries. Can access your .Net Libraries. Can host 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. Supports Delphi 2010 and higher versions Supports both 32bit and 64bit delphi application and many more. The Runtime Library includes .Net DLL/WSDL Importer for Delphi which is used for importing .Net Assemblies, WSDL or web service XML schema and for generating Delphi classes from the .Net types of the imported assemblies. Example: program LoadDotNetAssembly; {$APPTYPE CONSOLE} {$R *.res} uses {$IF CompilerVersion > 22} System.SysUtils, {$ELSE} SysUtils, {$IFEND } CNClrLib.Host, CNClrLib.Core; var oConsole : _Console; oAsmHelper : _AssemblyHelper; oAssembly : _Assembly; procedure DisplayAssemblyInfo(xAssembly : _Assembly); begin if xAssembly = nil then oConsole.WriteLine_14('Assembly cannot be loaded') else begin oConsole.WriteLine_14('Assembly has been loaded'); oConsole.WriteLine_15('Global Assembly Cache: {0}', xAssembly.GlobalAssemblyCache); oConsole.WriteLine_15('Is Fully Trusted: {0}', xAssembly.IsFullyTrusted); oConsole.WriteLine_15('Location: {0}', xAssembly.Location); oConsole.WriteLine_15('Image Runtime Version: {0}', xAssembly.ImageRuntimeVersion); oConsole.WriteLine_15('Number of Types: {0}', xAssembly.GetTypes.Length); oConsole.WriteLine; oConsole.WriteLine; end; end; procedure LoadAssemblyFromFile; begin oConsole.WriteLine_14('System.Data.dll using Assembly File'); oAssembly := oAsmHelper.LoadFrom('C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Data.dll'); DisplayAssemblyInfo(oAssembly); end; procedure LoadAssemblyByAssemblyName; var oAssemblyName : _AssemblyName; begin oConsole.WriteLine_14('Loading System.Data.dll using AssemblyName Properties and methods'); oAssemblyName := CoAssemblyName.CreateInstance; oAssemblyName.Name := 'System.Data'; oAssemblyName.Version := CoVersion.CreateInstance('2.0.0.0'); oAssemblyName.CultureInfo := CoCultureInfo.CreateInstance(''); oAssemblyName.SetPublicKeyToken(TClrArrayHelper.ToByteArray('b77a5c561934e089')); oAssembly := oAsmHelper.Load_1(oAssemblyName); DisplayAssemblyInfo(oAssembly); end; procedure LoadAssemblyByAssemblyNameString; var oAssemblyName : _AssemblyName; begin oConsole.WriteLine_14('Loading System.Data.dll using AssemblyName with AssemblyString'); oAssemblyName := CoAssemblyName.CreateInstance('System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'); oAssembly := oAsmHelper.Load_1(oAssemblyName); DisplayAssemblyInfo(oAssembly); end; procedure LoadAssemblyWithPartialName; begin oConsole.WriteLine_14('Loading System.Data.dll using Partial Assembly Name'); oAssembly := oAsmHelper.LoadWithPartialName('System.Data'); DisplayAssemblyInfo(oAssembly); end; procedure LoadAssemblyByFilePath; begin oConsole.WriteLine_14('Loading System.Data.dll using File Path'); oAssembly := oAsmHelper.LoadFile('C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Data.dll'); DisplayAssemblyInfo(oAssembly); end; begin oConsole := CoConsole.CreateInstance; oAsmHelper := CoAssemblyHelper.CreateInstance; oConsole.WriteLine_14('Hello! Welcome to .Net Runtime Library for Delphi.'); oConsole.WriteLine_14('=================================================='); oConsole.WriteLine_14('The program demonstrate how to use Static Assembly to Load .Net Assemblies'); oConsole.WriteLine; try LoadAssemblyFromFile; LoadAssemblyByAssemblyName; LoadAssemblyByAssemblyNameString; LoadAssemblyWithPartialName; LoadAssemblyByFilePath; except on E:Exception do oConsole.WriteLine_15('Exception : {0}', E.Message); end; oConsole.ReadKey; end. For more information about the Runtime Library, go to https://www.crystalnet-tech.com/RuntimeLibrary/RuntimeLibrary4Delphi. For more information about the Import Utility, go to https://www.crystalnet-tech.com/RuntimeLibrary/RuntimeLibUtilities. For more development code samples, go to: https://www.crystalnet-tech.com/DevCodeSamples/Default. Edited September 20, 2019 by CrystalNet Remove prefix tags 1 Share this post Link to post