Interoperability C # and NAV 2016


I'm around trying to create an interoperable dll written in C # for use in Microsoft NAV 2016, for the development of a fiscal printer driver. In my C # project I called to other functions dll (delivered by the company Bematech, in 32-bit and unmanaged).

Calls to the functions of the dll unmanaged (and tested from an .EXE) I make as follows:

[DllImport ( "BemaFi32.dll")]
public static extern int Bematech_FI_ProgramaAlicuota (Aliquot string, int ICMS_ISS);

When I try to run it from the NAV2016 I get the following error: .A call to "MyAssembly" failed with this message: You are trying to load a program with an incorrect format. Expection from HRESULT: 0x8007000B

I guess the error because the dll is not managed or 32-bit version (if that's the problem becomes more difficult because apparently there is no 64-bit version). Not how to solve the problem.

asked on Stack Overflow Sep 9, 2016 by Ivanrlg • edited Oct 2, 2019 by Vadim Kotov

2 Answers


NAV cannot work with unmanaged code. The only way is to write a wrapper dll which can be called from NAV. Microsoft is doing the same with the Office SDK for example...


answered on Stack Overflow Sep 9, 2016 by azatoth

The problem was not the embedded dll unmanaged, was that the new dll to be 32 bit was not compatible with the client NAV, the solution was to change the 32bit client as follows:

Rename the file to Microsoft.Dynamics.Nav.Client.X64.exe Microsoft.Dynamics.Nav.Client.exe, and then a Microsoft.Dynamics.Nav.Client.X86.exe rename the file to Microsoft.Dynamics.Nav.Client. exe.

and the C / AL change in the variable declared the call to the dll Property Value Yes RunOnClient

answered on Stack Overflow Sep 13, 2016 by Ivanrlg

User contributions licensed under CC BY-SA 3.0