Wednesday, November 4, 2009

How to: Debug User Controls

You can use Visual Studio to debug the code used in User Controls. You can debug when the User Control is being run in the ASP.NET Development Server environment or in Enterprise Portal.

[http://i.msdn.microsoft.com/Global/Images/clear.gif] Debugging in the ASP.NET Development Server Environment

To debug a User Control in the ASP.NET Development Server environment, you must create a Dynamics AX Webpart Page that will run the User Control. For more information, see How to: Test User Controls in Visual Studio.

To debug in the ASP.NET Development Server environment

1. Start Visual Studio.

2. Open the Web project that contains the User Control that you want to debug.

3. View the code for the User Control. Do this by right-clicking the User Control in Solution Explorer, and then clicking View Code.

4. Add breakpoints to the appropriate locations in the code.

5. In the Debug menu, click Start Debugging.

6. In the Web browser window that is displayed, click the file name for the Dynamics AX Webpart page (.aspx) that contains the User Control that you want to debug. Visual Studio should stop execution at the designated breakpoints.

[http://i.msdn.microsoft.com/Global/Images/clear.gif] Debugging in Enterprise Portal

To debug a User Control that is running in Enterprise Portal, you must configure Web project appropriately and enable debugging for the Enterprise Portal Web site.

To debug in Enterprise Portal

1. Start Visual Studio.

2. Open the Web project that you want to use for debugging.

3. Add the User Control to the Web project.

4. If the User Control uses any proxies to access X++ code, right-click the App_Code node in Solution Explorer, and then click Generate Proxies. The proxies that are required to access X++ code will be added to the Web project.

5. Copy the complete URL for the page in Enterprise Portal that contains the User Control that you want to debug. This URL is needed when configuring Visual Studio.

6. Select the Web site in Solution Explorer.

7. In the Website menu, click Start Options.

8. Set the Start action to Start URL. Specify the complete URL for the page that contains the User Control.

9. Set Server to Use custom server. Specify the Base URL for the server that is running Enterprise Portal. For example, http://daxep.

10. Click OK.

11. To enable debugging for the Enterprise Portal installation, right-click the Web site in Solution Explorer. Click Enable Debugging in SharePoint.

[Important]Important

If you do not see the Enable Debugging in SharePoint item in the menu, debugging may have already been enabled for the Web site. You might also have to restart Visual Studio and re-load the Web project for the menu item to be visible.


12. In the dialog box displayed, indicate that you want to enable debugging and click OK.

[Important]Important

Enabling debugging will modify the web.config file for the Enterprise Portal site. We do not recommend that you enable debugging in production environments for Enterprise Portal.


13. View the code for the User Control. Do this by right-clicking the User Control in Solution Explorer, and then clicking View Code.

14. Add breakpoints to the appropriate locations in the code.

15. In the Debug menu, click Start Debugging. The page that you specified will be loaded, and Visual Studio should stop execution at the designated breakpoints.

No comments:

How to identify the user that was used to change an object from AOT in AX2012

Get the object name for which we need to track these (user and date&time) information's. Login to SQL Server Management Studio an...