Tuesday 11 March 2014

Debug AX 2012 Retail Online Store commerce runtime services

Pre-requisites:
  1. Install Retail SDK (http://technet.microsoft.com/en-us/library/hh771575.aspx)
  2. Locate the Retail SDK from the installed location (Eg. C:\Users\Administrator\Documents\Retail SDK)
    *You may duplicate this folder to any other location
  3. Sign the Retail SDK source code with your strong name key
    (Follow the “Prepare your developer environment for signing updated source code” section in http://technet.microsoft.com/en-us/library/dn387566.aspx)

    Eg.
Debug CRT (Commerce Runtime Services)
  1. Open the Commerce runtime solution file
    Eg. \Retail SDK\Commerce Run-time\Services\Services.sln
  2. Clean the solution
  3. Then build the solution

  4. Put the CRT DLL to GAC
    Eg. 
    gacutil /i Microsoft.Dynamics.Commerce.Runtime.Services.dll
    gacutil /i Microsoft.Dynamics.Commerce.Runtime.Services.PricingEngine.dll


  5. Locate the “commerceRuntime.config” file of the online store

  6. Update the commerceRuntime.config with your public key token (Eg. The public key token [$newStrongNameKeyHash] in Pre-requisites Step 3) and update the version as well

  7. Make a dumb update to the “web.config” file (Eg. Enter a space character and delete it, then save the file so that the file appear to have no changes to its content but the modified date time has changed)
  8. Then restart the IIS or recycle the application pool of the Online store

    *Step 6 & 7 are optional, do that in case the debugging didn't pick up the latest changes
  9. In Visual Studio, attach to Online store process
    > Menu: Debug > Attach to Process…


    > Select the “w3wp.exe” process that’s used by the Online store
    =>> If the process does not shows up in the list, check the checkbox “Show processes from all users”
    =>> If there’re multiple “w3wp.ese” processes and you’re unsure which one is the Online store process, it usually has the same user name as the application pool
    =>> if there’re multiple “w3wp.ese” with the same user name, one of the quick method is to open up Task Manager, sort by the process name descending, click on any link on the Online store, usually the Online store process will have higher CPU usage for awhile, that’s most likely the process for the Online store. Take note of the PID of that process and select this ID in the “Attach to Process” window.
    =>> If you need a proper way to find the PID, refers to this link: http://blogs.msdn.com/b/benjaminperkins/archive/2011/12/05/finding-the-w3wp-worker-process-pid-and-associated-id.aspx



    Confirm the security warning by click on the “Attach” button

  10. Put breakpoint to the code you wanted to debug, the breakpoint will appear in solid red dot.
    *If it appear as circle instead of red dot, it means the symbol is not properly loaded, that’s probably one of the steps above has not been done correctly.






  11. Run the process that you wanted to debug (Eg. Click on the link on the Online store that will trigger the breakpoint)

No comments:

Post a Comment