The most popular language in every day work is C#. It’s based on the C language, constantly supported and developed with additional functions.
.NET Framework has its own structure, which we can divide as follows:
- Class libraries (e.g. ASP.NET, Web Services, Web Forms, XML, ADO.NET etc.)
- Own runtime environment (CLR)
- Visual Studio .NET
There are two possibilities for implementing .NET libraries in Dynamics NAV.
- We can use ready-made DotNet library (we have to create new variable with DotNet data type and select library from the list.
- We can create new .NET library.
This example can illustrate, how to implement own .NET scripts in Dynamics NAV.
Step 1. Run Microsoft Visual Studio (e.g. free version of this program Visual Studio 2017 Community) and create new project. Click on the File tab and then New – Project.
Step 2. On the list, find Class Library (.NET Framework) and set project name in Name field.
Step 3. Write script code (in C#) which will be implemented in NAV.
Step 7. Run Microsoft Dynamics NAV and create a new Codeunit, where you will use your library. Then you have to declare a new variable with DotNet DataType.
Step 8. In Subtype field, press F6 and go to the Assembly by clicking an arrow icon. Find your file in a Server tab.
Step 9. After creating a new variable, you can declare new code using .NET script from your DotNet library. Your code can look like the one on this screenshot.
Step 10. Run this codeunit, and see the effects of our work.
Done! You implemented your own .NET class library in Dynamics NAV.