Dynamics NAV and serial port (RS232) Communication

Hi, I need to write a code for communication between NAV 2016 and weigh bridge scales. Communication needs to be done trough serial port (RS 232). Nav needs to send information trough serial port, and in return it gets measured weight in string. Can you point me in the right direction please ?

Hi JuniorDEV,

You can try to use SerialPort Class dot net var:


You will need to check that dot net vars to “RunOnClient”, if the device is connected to user PC.

As an additional info, but a bit outdated:


Ok, i See, do you know is there any NAV examples with using this class, because I need to send some data and then recieve the answer from scale ? And I didn’t work with .NET classes so far.

I’ve never used this Class, but if you look for examples in Internet on how to use this Class, you’ll find a lot in C#, not in C/AL.



You will have to “translate” C# code to C/AL code.

I did like you suggested, and i found a problem I can’t solve, google is not much of a Help. I created a NETArray variable and it is a .NET byte array. And when i try to write byte to serail port using this command


It says this error

Microsoft Dynamics NAV Development Environment

The call is ambiguous between the following methods:

‘Write(char[] buffer, int offset, int count)’


‘Write(byte[] buffer, int offset, int count)’


I dont get why is this happening if I converted NETArray to byte array [emoticon:ca08b2c27c2f40e993e89508acf29e0b] Any suggestions ?

I not shure, but the system has a problem to execute correct Write function (thanks to function overload)… I think that char and byte are bassically the same var type. Anyway I don’t know how to solve this.

Only alternative to this is to use method Write(string) but I am not sure if this is going to work :frowning: I must wait monday to test this :confused: