Recently I was giving a presentation about Client Add-ins and it turned out that the audience had already seen all available material about Add-ins. So what could I show instead? Live programming of a new Add-in was what I came up with. The Add-in should be a traffic-lights type of state indicator. This is a control that shows one of three images based the value that arrives trough data binding.

Of course, what happened when I tried to run the RoleTailored client with the first build of the new Add-in – it failed from an exception thrown by faulty code in the Add-in.

Idea

 

Please note: The Add-in is responsible for catching and handling any exception, which might occur in its code execution.

 

In order not to lose the rest of goodwill of my audience, I had to deliver a piece of information, which would nicely camouflage my blunder. I decided on showing debugging of an Add-in the NAV RoleTailored client.

clip_image004

Debugging of an Add-in in the client is very simple. After the client has started up all you need to do is to attach the Visual Studio to the process of the RoleTailored client.

For debugging compile your project with the “Debug” solution configuration.

Before you open the page that contains your Add-in attach Visual Studio to the process “Microsoft.Dynamics.Nav.Client.exe”.

Now you can monitor the program flow in your Add-in code. Go ahead and set breakpoints in the implementation of CreateControl or in your implementation of the IObjectControlAddInDefinition interface.

 

Idea


You think it is too cumbersome to attach the debugger from Visual Studio each time you run the client?
Then consider adding the following code line in the CreateControl method:

 

System.Diagnostics.Debugger.Launch();

 

This will fire up a dialog where you can pick the instance Visual Studio and for debugging and already breaks at that code line. Remember to remove this line, when you are done with debugging ;-)

 

After I had found the typo in my Add-in code with the help of debugging, I then could conclude the session just is time. So debugging of Add-ins while running in the RoleTailored client is a helpful thing. Give it a try!

Christian Abeln
Senior Program Manager
Microsoft Dynamics NAV