Показать сообщение отдельно
Старый 12.04.2018, 06:16   #1  
Blog bot is offline
Blog bot
Участник
 
25,459 / 846 (79) +++++++
Регистрация: 28.10.2006
stoneridgesoftware: Quick Modification for Tracing Bug Code in a Dynamics AX Production Environment
Источник: https://stoneridgesoftware.com/quick...n-environment/
==============

This quick modification for tracing bug code in a Dynamics AX production environment was used at a client site. I have received their permission to blog about this as I thought it was pretty useful.

Basically, the modification consists of the creation of an empty security role. When a user reports a bug, they may be asked for more detailed repro steps within the production environment. The user will be added to this security role, which will trigger the dumping of the X++ call stack into the Infolog when the error is generated. Once the repro is complete, the user is simply removed from the security role, and the logging is stopped. For the bug repro, the user may need to have running code in CIL disabled so the full call stack can be retrieved as well.

Part 1. Create an empty security role in the system
  • Navigate in the Dynamics AX 2012 client System administration > Setup > Security > Security roles
  • Click the New button
  • Fill in pertinent information

  • Click the Close button
Part 2. Modify the info class, add() method

Change the method to the following code (no changes in the latter half of the method, so just make the displayed modifications:

Exception add( Exception _exception, str _txt, str _helpUrl = '', Object _sysInfoAction = null, boolean buildprefix = true){ int numOfLines,i; int actionClassId; container packedAction; xSession session; // START - Add callstack to infolog #Define.mySecurityRole('EnableAXDebugging') System.Diagnostics.StackTrace myStackTrace; container myCallStack; int cntr; str1260 whatToWrite; SecurityUserRole securityUserRole; SecurityRole securityRole; boolean dumpCallStack = false; while select AotName from securityRole join securityUserRole where securityUserRole.User == curUserId() && securityUserRole.SecurityRole == securityRole.RecId { if (securityRole.AotName == #mySecurityRole) { // if we find the security role, set our X++ call stack dump variable, and quit searching as we are done dumpCallStack = true; break; } } if (dumpCallStack) { // determine if running as native X++ or as IL code if (xSession::isCLRSession()) // IL code { myStackTrace = new System.Diagnostics.StackTrace(true); _txt += ' - ' + myStackTrace.ToString(); } else { myCallStack = xSession::xppCallStack(); for(cntr=1; cntr Common > Users. Select the user by double-clicking, and add the security role to the user by clicking the Assign roles button</p>

Click the OK button once the debugging role has been selected.

Part 4. If needed, disable running business logic in CIL

In the client, navigate File > Tools > Options > Development tab. Uncheck the Execute business operations in CIL checkbox



Click the Close button.

At this point, you should be able to run a process, and see the call stack in the Infolog when the error is generated.



Once this has been captured, simply go back into the user, and remove the debugging security role from the user. If the Execute business operations in CIL checkbox was modified, go back and correct that setting as well.

I hope that you find this useful, and it provides you something you can add to your ‘bag of tricks’ for debugging or troubleshooting any Dynamics AX issues.



Источник: https://stoneridgesoftware.com/quick...n-environment/
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.