How to: Attach Visual Studio to the Microsoft Dynamics NAV Server Service
You use Visual Studio to debug objects that run in the RoleTailored client.
This procedure describes how to attach Visual Studio to the Microsoft Dynamics NAV Server service before you start debugging.
Before you start this procedure, you must do the following:
Enable Microsoft Dynamics NAV 2009 for debugging. For more information, see How to: Enable Debugging. After you enable Microsoft Dynamics NAV 2009 for debugging and then start the RoleTailored client, the C# files for RoleTailored client objects are created.
Install Visual Studio 2005 SP1 or Visual Studio 2008 SP1 on the computer running Microsoft Dynamics NAV Server.
To attach Visual Studio to the service
Start Visual Studio.
On a computer running Windows Vista with User Access Control enabled, you must start Visual Studio with administrator privileges. To do this, click Start, right-click Microsoft Visual Studio, and then click Run as administrator.
In Visual Studio, open the C# file for the object that you want to debug. By default, when you enable Microsoft Dynamics NAV 2009 for debugging and then start the RoleTailored client, the C# files are created in the following folder: %systemdrive%\ProgramData\Microsoft\Microsoft Dynamics NAV\60\Server\MicrosoftDynamicsNavServer\source\<object>\
On the Debug menu, click Attach to Process.
In the Attach to Process window, select the Show processes from all users check box and the Show processes in all sessions check box.
Under Available processes, select Microsoft.Dynamics.Nav.Server.exe from the Available Processes list.
Above the Available Processes list, next to Attach to, click Select.
In the Select Code Type window, select Debug these code types, select Managed from the list of code types, and then click OK.
Debugging T-SQL code types is not supported. If you attach the debugger to T-SQL code while the RoleTailored client is running, then the client does not respond. If you attach the debugger to T-SQL code and then start the RoleTailored client, then you get an error that is similar to the following:
The following SQL Server error or errors occurred:
2812,"42000",[Microsoft][ODBC SQL Server Driver][SQL Server]Could not find stored procedure 'sp_sdidebug'.
5703,"01000",[Microsoft][ODBC SQL Server Driver][SQL Server]Changed language setting to us_english.
0,"01000",[Microsoft][ODBC SQL Server Driver]SQL Debugging disabled
5701,"01000",[Microsoft][ODBC SQL Server Driver][SQL Server]Changed database context to 'master'.
In the Attach to Process window, click Attach.
Start using the RoleTailored client. When you hit a breakpoint, you can begin debugging in Visual Studio. For more information, see Debugging in Visual Studio.