While Microsoft SQL Server Reporting Services (SSRS) reports allowed in in Dynamics AX 4.0 a user to create Ad'hoc reports that were only based on the data stored in the Dynamics AX database, in Dynamics AX 2009 Production reports allow also the execution of Business Logic. The Business Logic can either be X++ code in the AOT or C# code directly in the SSRS report.

This also brings up the question how the C# code could be debugged when necessary. You can use the Visual Studio 2008 integrated debugger however you need to follow certain steps otherwise your breakpoints will not be hit.

You need a PC where the following components are installed:

  • Microsoft Dynamics AX 2009 Client,
  • Microsoft Dynamics AX 2009 Reporting Tools,
  • Microsoft SQL Server 2005 or 2008 Reporting Services,
  • Microsoft Dynamics AX 2009 Reporting Extensions, and
  • Microsoft Visual Studio 2008

Note:
In the following example we use a report that is based on Microsoft SQL Server Analysis Services (SSAS) data. Therefore the Dynamics AX default cubes need to exist, however SSAS does not necessarily need to be locally installed.
 

In the following steps I will explain how you can debug the standard SSRS / SSAS report Cust.CashInflowvsCashOutflow for example:

  1. Start the Dynamics AX Client, open the AOT window and go to AOT\Report Libraries
     
  2. Click with the right Mouse button at the Cust report library and select Edit in Visual Studio from the context menu
     
  3. Wait until the Visual Studio IDE has launched completely
     
  4. Make sure the active configuration of the Solution is set to Debug (to check the Active configuration go to Build - Configuration Manager...)
     
  5. Rebuild the whole Solution by selecting Build - Build Solution
     
  6. Deploy the Solution to your Microsoft SQL Server Reporting Services by selecting Build - Deploy Solution
    (Note: It is important to deploy the Solution from within Visual Studio even if the SSRS reports were already deployed and did not change since then!)
     
  7. Open the report CashInflowvsCashOutflow from the Visual Studio Solution Explorer window
     
  8. In the Report Explorer window expand the node Data Methods and double click at GetDefaultCompany 
     
  9. Place a breakpoint (e. g. by pressing the [F9] key) at any line of code
     
  10. Start the Internet Explorer and navigate to your Microsoft SQL Server Reporting Services Report Manager page (e. g. http://localhost/reports)
     
  11. Click at the Dynamics folder in the Report Manager page
     
  12. Go back to Visual Studio and select Tools - Attach to Process from the menu
     
  13. Make sure the options Show processes from all users and Show processes in all sessions are enabled (checked)
     
  14. The next step is different based on the version of Microsoft SQL Server Reporting Services:
    1. If you are using Microsoft SQL Server 2008 Reporting Services:
      In the list of processes located the process ReportingServicesService.exe and attach to this process
       
    2. If you are using Microsoft SQL Server 2005 Reporting Services:
      In the list of processes located the process w3wp.exe and attach to this process (If you have more than one w3wp.exe process listed, see the appendix at the end how to determine the correct process)
       
  15. Go back to the Report Manager page in Internet Explorer and execute the report Cust.CashInflowvsCashOutflow.FullPage
     
  16. The breakpoint will be hit by the Visual Studio integrated debugger
     

Some more hints:

  • On Windows Vista and Windows Server 2008 make sure you run Visual Studio with elevated privileges (Run as Administrator)
     
  • Once the debugger is attached you can check what modules are loaded in the Visual Studio integrated debugger by selecting Debug - Windows - Modules from the menu (The Assembly the C# code is compiled to is Cust.BusinessLogic.DLL)
     

How can I determine the correct w3wp.exe process to attach to?

The Microsoft SQL Server Reporting Services 2005 are hosted in the Microsoft Windows Server Internet Information Services (IIS). Therefore the process to attach to for debugging is the IIS Worker Process (w3wp.exe). As IIS is starting at least one Worker Process per Application Pool, more than one w3wp.exe processes are usually running on a Windows Server.

In order to see what Worker Process is serving what IIS Application Pool tools exists:

  • On Windows Server 2003 (IIS 6.0) run: iisapp.vbs
  • On Windows Server 2008 (IIS 7.0) run: appcmd.exe list wp

The output of the tools looks as follows:

C:\Windows\system32>iisapp.vbs
W3WP.exe PID: 2056 AppPoolId: AxReportServer
W3WP.exe PID: 5092 AppPoolId: EP - 39014

C:\Windows\system32\inetsrv>appcmd.exe list wp
WP "6916" (applicationPool: SharePoint Central Administration v3)
WP "1356" (applicationPool: AxReportServer)

Once identified the correct w3wp.exe process (based on the Application Pool) use the PID (Process ID) to attach to the correct w3wp.exe process.

--author: Alexander Lachner
--editor: Alexander Lachner
--date: 16/06/2009