Microsoft.NET API

If you are a Microsoft.NET programmer who wants to run the Dynamics NAV Role Tailored Client from a command line then the .NET API is for you. You can use it from C#, VB.NET, or any other programming language that supports the use of .NET assemblies.

The assembly is fully managed and strong named. It is also self contained, which means that it does not have any other external dependencies. It supports .NET 4 and both 32 and 64 bit.

You can use the assembly to launch NAV directly or to create the bookmarks needed to identify records in NAV.

Using the Assembly in your Project

All you need to do to use the assembly in your .NET project is to add a reference to the DLL. In a normal installation the DLL is found in C:\Program Files\NAV Start\API\Microsoft.NET\Framework\v4.0. The name of the assembly is MoreNav.Launcher.dll.

Launching NAV RTC

The following example will show how you can show customer 10000 using default values for client executable, server address, and company name.

Using MoreNav;
...
Launcher launcher = new Launcher();
launcher.RunNav(null, null, null, 21, 18, new Launcher.KeyField[] {
    new Launcher.KeyField(Launcher.FieldType.Code, "10000") }
    );

In the next code snippet you will see the same code but with specific values for client executable, server address, and company name.

Using MoreNav;
...
Launcher launcher = new Launcher();
launcher.RunNav(@"C:\Program Files (x86)\Microsoft Dynamics NAV\71\RoleTailored Client\Microsoft.Dynamics.Nav.Client.exe",
    "localhost:7046/dynamicsnav71", "CRONUS International Ltd.", 21, 18, 
    new Launcher.KeyField[] { new Launcher.KeyField(Launcher.FieldType.Code, "10000") }
    );

Creating Bookmarks

If you only want to create the bookmark for a specific record then you can use the CreateBookmark function of the .NET API.

It works very similar to launching the RTC client. However, you do not have to specify a client executable, server address, or company name. The bookmark itself only depends on the table number and the values of the primary key.

Bookmark syntax can vary between NAV version. Therefore, you have to specify the version of the client. When you use the RunNav function it will look at the version number of the executable that you specify. However, that is not possible here because you do not specify any. 

Using MoreNav;
...
Launcher launcher = new Launcher();
string bookmark = launcher.CreateBookmark(18, new FileVersion(7, 0, 0, 0), new Launcher.KeyField[] { 
    new Launcher.KeyField(Launcher.FieldType.Code, "10000") }
    ); 

Note on Primary Keys 

In case your table has a primary key with more than one field then you should add additional KeyField(s) to the array. It is important that you specify types and values for all the fields in the primary key and in the exact same order as in the definition of the primary key.