Business Central OnPremise – DotNet assembly integration in Microsoft AL

Business Central OnPremise – DotNet assemby integration in Microsoft AL

This short post to show you how to use DotNet assemblies in Business Central OnPremise, it might be useful to declare and use them in Microsoft AL.

Risultato immagine per dotnet

STEPS

First of all it is necessary to set the target in the app.json file, in this case is target is “OnPrem” (for Cloud (for Cloud/SaaS I will test Blazor shortly in a future post)

After this, it’s necessary to modify the settings.json of VsCode in order to integrate the paths where the dotNet assemblies reside.

Example

File – Preferences – Settings –  Extensions – AL Language Extension

Select “Modify in settings json

cid:image002.png@01D7054B.6F923D60

In this “SETTINGS.JSON” file, you need to insert the assembly path for assembly reference

“al.assemblyProbingPaths”:[

“./.netpackages”,

“C:/Windows/assembly/”

]

Once this is done, it’s necessary to declare in our .AL file which assemblies to load

example: ASSEMBLY name: “mscorlib”

As a result we will have (at the beginning of our AL script)

…and so on for all the DotNet libraries to use

VAR

The declaration of the VAR section becomes:

TEST CASE – “System.Datetime”

Quick test with System.Datetime located in mscorlib and System.environment

Demo Link

https://github.com/rstefanetti/AL-Code-Samples-Education/tree/dotNet-in-Microsoft-AL