Sunday, August 26, 2012

Debugging in NAV 2009,2009SP1 & NAV2009R2 RTC Client

Hi all,

With the new client version of Navision the debugging process have also been changed.

This post contain details of NAV 2009, NAV 2009 SP1 and NAV 2009 R2 RTC Client.

First step is to Stop the Microsoft Dynamics NAV Server Service.

Then we  need to don EnableDebugging in CustomSettings.config found here: C:\Program Files\Microsoft Dynamics NAV\60\Service.

Now start the Microsoft Dynamics NAV Server Service.
Now we have debugging enabled. Now start the RoleTailored client. This will take a bit longer to start up, because C# files are generated for each of the objects. (Pages, Codeunits, Reports etc.) - .cs files will be created.
In this example I will make a codeunit with a simple message and add this to an action on the Customer list.
Create a Codeunit. Ex. 50000
OnRun trigger place the following code: MESSAGE ('Debug test')

Save and compile Codeunit 50000.
Now let us add this codeunit to a action. Design page 22 and navigate to the Actions on page 22.

Insert a new action below the the Customer Action group

Hit F9 and enter this code on the Debug test -  OnAction trigger: CODEUNIT.RUN(50000);
Save and compile page 22

we now have all code completed so now let us set a breakpoint in Visual Studio.
Navigate to “C:\ProgramData\Microsoft\Microsoft Dynamics NAV\60\Server\MicrosoftDynamicsNavServer\source\Codeunit” IN WINDOWS 7
Assuming that you have Visual Studio installed, (In my case I’m using Visual Studio 2008 with SP1) open Codeunit50000.cs
If you have UAC turned you will need to open Visual Studio with “Run as administrator”.
Now we need to attach the NAV service. Select “Debug / Attach to process…”
Attach Microsoft.Dynamics.Nav.Server.exe
Your screen should now look like this:
Now add a break point on the message “Debug test”
With this done now let us go to RoleTailored client.
Navigate to Customer List and see that you have a new action called “Debug test” under “Related Information”
Now select “Debug test”
Visual Studio will come back in focus with the breakpoint selected.

Now try to hit F5 and debugging will continue and RoleTailored client will come back in focus and show the message “Debug test”:
"In Next post i will discuss the Debugging Process in NAV 2013 which is an enhanced version of Debugging. i Personally feel that its a better version than debugger in classic client and RTC Client till NAV 2009 R2."
Saurav  Dhyani

No comments:

Post a Comment

Popular Posts