NAV Design Pattern: TryFunction – .NET Exception Handling in C/AL

When you want to use objects from the .NET Framework in C/AL code, one of the main challenges is to handle exceptions that the methods of these objects¬†may throw. Eventually, if not handled, they will basically bubble up as runtime errors, halting the current operation a user is doing without having a chance to properly… Read more

.NET Exception Handling in C/AL

This pattern is brought to you by Mostafa Balat from the Dynamics NAV team here at MDCC in Denmark. Best regards, The NAV Patterns team Meet the Pattern When there is a need to use .NET classes within C/AL, one of the main challenges is to handle the exceptions the methods of these .NET classes may… Read more

Control Add-In dll’s files in Microsoft Dynamics NAV 2015

With Microsoft Dynamics NAV 2015 there comes one feature in Add-In files area – you do not need manually to copy add-in dll to client: when client doesn’t find it, NAV copies add-in from server. It is very good: If you’ve installed NAV client on some computer, you don’t care about all add-ins, when user… Read more

How to control keyboards events in Add-in

With Microsoft Dynamics NAV Role Tailored Client we’ve received possibility to add ControlAddIn to any field on page. This opens huge possibilities to extend functionality with own controls. We can create any .Net control with Visual Studio, register it in NAV controls and add it to any field on page by describe control name in… Read more

Memory usage when is used .NET components

We already had few support request where NAV developers see big memory consumption increase when using .NET component.Especially when method is inside some loop.Like in this sample:   FOR count := 1 TO 10000000 DO BEGIN        varDOTNET :=varDOTNET.DotNetObject();        varDOTNET.SetValue(‘par’);        CLEAR(varDOTNET);   END;   Even it looks like we create variable and then clear it – we can… Read more

“Timer” usage in Microsoft Dynamics NAV 2013

Last time we have seen our “old” NTimer.dll was Microsoft Dynamics NAV 2009. It was placed in  ..\Common\Microsoft Dynamics NAV\Timer.. folder. Usually we have used it for NAS or other looping tasks. We want to have the same in Microsoft Dynamics 2013 and later, however we see that the same doesn’t work anymore. So how… Read more

Working with SQL Server through .NET Interop

The Upgrade Toolkit objects that shipped with Microsoft Dynamics NAV 2013 have a good example of code that works directly with SQL Server through the .NET Framework library. On the product media, navigate to this location: ..\UpgradeToolKit\Data Conversion Tools\601\ Import the Upgrade 601700.2.fob file. This contains codeunit 104050 Upgrade – SQL Mgt.: and codeunit 104049… Read more

Add attachment stream on SMTP not always working

This week I did work on a support case where the partner mentioned that adding an attachment from a stream does not always work. The partner delivered a code unit that we used to further analyze the issue. As it was not necessary to further develop a fix for this, we decided to just post… Read more

Reading and Writing Unicode Files using C/AL

Hello, We have had some partner suggestion for adding Unicode capabilities to the existing Microsoft Dynamics NAV File functions. What we recommend is to use .NET Interop to achieve this functionality. For example, you can use an instance of the System.IO.StreamWriter class to write to an OutStream or the System.IO.StreamReader class to read from an InStream. You… Read more

Let NAV BEEP! (with .NET Interop and Microsoft Dynamics NAV 2009 R2)

It is known that in Role Tailored Based environment BEEP C/AL function is not supported. This simple blog is based on SystemSounds Class from System.Media namespace  My Ingredients : NAV 2009 R2 Role Tailored Client Windows 7 Enterprise Attached you will find 1 unbounded page object in TXT format. The code is fairly… Read more