UPDATE 25 August 2010! You cannot use the Express version of Visual Studio 2008 SP1 to debug Microsoft Dynamics NAV 2009.
UPDATE: Debugging is not available in the Marketing Beta, so if you have access to a later build you can try this out. If not you will have to wait for RTM.
Also note that SP1 for either Visual Studio 2005 or Visual Studio 2008 is required.
In this post I will give you a example on how to debug in NAV 2009.
1. EnableDebugging in CustomSettings.config found here: C:\Program Files\Microsoft Dynamics NAV\60\Service
2. Now Restart the “Microsoft Dynamics NAV Server” service
3. 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.)
4. Now we need to find a place to debug. In this example I will make a codeunit with a simple message and add this to an action on the Customer list.
5. Create a Codeunit. Ex. 50000
6. OnRun trigger place the following code: MESSAGE (‘Debug test’)
7. Save and compile Codeunit 50000.
8. Now let us add this codeunit to a action. Design page 22 and navigate to the Actions on page 22.
9. Insert a new action below the the Customer Action group
10. Hit F9 and enter this code on the Debug test – OnAction trigger: CODEUNIT.RUN(50000);
11. Save and compile page 22
12. OK we now have all code completed so now let us set a breakpoint in Visual Studio.
13. Navigate to “C:\ProgramData\Microsoft\Microsoft Dynamics NAV\60\Server\MicrosoftDynamicsNavServer\source\Codeunit”
14. Assuming that you have Visual Studio installed, (In my case I’m using Visual Studio 2008 with SP1) open Codeunit50000.cs
15. If you have UAC turned you will need to open Visual Studio with “Run as administrator”.
16. Now we need to attach the NAV service. Select “Debug / Attach to process…”
17. Attach Microsoft.Dynamics.Nav.Server.exe
18. Your screen should now look like this:
19. Now add a break point on the message “Debug test”
20, With this done now let us go to RoleTailored client.
21. Navigate to Customer List and see that you have a new action called “Debug test” under “Related Information”
22. Now select “Debug test”
23. Visual Studio will come back in focus with the breakpoint selected.
24. Now try to hit F5 and debugging will continue and RoleTailored client will come back in focus and show the message “Debug test”:
We're always looking for feedback and would like to hear from you. Please head to the Dynamics 365 Community to start a discussion, ask questions, and tell us what you think!