martes, 8 de mayo de 2012

How to Debug RTC and Web Services remotely


The main goal of this post is to explain how to set up a test environment in pursuance of debugging RTC Client and Dynamics NAV 2009 Web Services.
In the example, it will be shown a Preproduction server with a Dynamics NAV 2009 Database and the Microsoft Dynamics NAV Server and Business Web Services.
Finally, it will be possible to debug from a local computer to the RTC Client and Web server in Preproduction server.

Prerequisite Components

Firstly, install Microsoft Visual Studio 2008 in the local Computer where we are going to debug. The 2010 version  is not compatible for debugging and neither for developing RDLC reports.
In the following example is used to debug the 2008 version.

Secondly, install the Microsoft Visual Studio Remote Debugger in the Preproduction Server where we are running the Microsoft Dynamics NAV Server and Business Web Services the Microsoft Visual Studio Remote Debugger. The same version that Visual Studio in local machine.


Visual Studio Remote Debugger Setup

Once installed Visual Studio Remote Debugger in Preproduction Server,should be set the Remote Debugger component by running the next option.

 In our environment we have the Preproduction server in 64 bits but the Microsoft Dynamics NAV Server runs in 32 bits. Because of that, the first option will be selected and the message accepted..

After that, the screen below will appear. The "username" is the name of the user who ran in the server machine and it must be an admin user :

In order to add users for debugging with remote option, should be set up options and permissions :

In the Server name it will be add the username.

Click Permissions.

Finally, click the “Add” button and add the user name with the permission to connect to Remote Debugger.
It will appear the message below and accept.

Note: In Order to run it correctly, it is necessary to setup the visual remote debugging as an admin user.

Dynamics NAV Server Setup (Service)

In order to be able to debug in the RTC Client and NAV Web Service, it is important to enable Debugging option in CustomSettings.config file. The file is in the custom installation in the next path.

Activate the “EnableDebugging” parameter.

Re Start the Dynamics NAV service, and the next time that we run RTC .

The upper message means that the server is creating the CSharp files for all the objects from the database and after that, it can be used in the debugging.
To finish the setup we should be able to access these files since our local machine where we are going to debug. For this purpose one option can be to have a map network drive to the folder where is  the files.
C:\Documents and Settings\All Users\Application Data\Microsoft\Microsoft Dynamics NAV\60\Server\MicrosoftDynamicsNavServer$DynamicsNAV\source

Now we are finally ready to start debug!!


With Microsoft Visual Studio running, click Open -> File

Open the object that it will be to debug in the map network drive (Page, Codeunit, etc).

Then click “Debug” and “Attach to Process”.

Before select the process, change the “Qualifier” field and put the username and servername instead of localhost.

Then, attach the process. If more than one Dynamics NAV server (service) is installed in the server, in order to know which it is the correct one the pointer can be moved over the process and it will show the path of this process. 

Click “Attach”.

FYI : navadminuser is the user which is running the Dynamics NAV server(service).
Finally,  all is prepared in order to start the debug. One last thing is to put the breakpoints with F9, and run the process of RTC or web service.

And that's all!

I hope that it was useful for you.

3 comentarios:

  1. Hey, this is a big post! Wow!
    Have you seen the new debugger in version 2013? It makes a huge difference.

    UsuariosNAV: A Dynamics NAV community

  2. Yes I saw. Is a big change and it has a lot of good enhancements. I want to write a post about it.

  3. Hola Albertino,
    Muchas gracias por tu post!! Muy bueno y muy bien explicado! Si señor!! Estaba buscando esta info hace semanas!!