The New Dynamics AX has certainly shown us new ways of working and for the developer the learning curve has been pretty steep.
With everything being Visual Studio for the developers new work routines are implemented and that goes for debugging as well.
Now, the Visual Studio debugger is great. So we are not losing any ground. We do however have to think a bit different in order to nail those tricky troubleshooting situations. In this post I will show how to debug the Commerce Runtime part of the Retail Server.
Step 1 – Getting the IIS ready
Navigate to the Retail Server folder. One way to get there is to open the IIS Manager. Locate and select the RetailServer in the Sites list to the left and select Explore. In the web.config file change
<compilation debug="false" targetFramework="4.5" />
<compilation debug="true" targetFramework="4.5" />
When you save the file you cannot save it to its original position. Save it to your desktop or somewhere else neutral and then copy it to the original folder.
Restart the IIS
Step 2 – Set the breakpoint
Now start up Visual Studio and open the solution CommerceRuntime in the RetailSDK folder \RetailSDK\Code\CommerceRuntime.
In the solution explorer locate the Discount.cs file in Runtime.PricingEngine project and add a breakpoint. Just to keep it simple I have put it into the constructor:
Step 3 – Start the Modern POS
Now it is time to fire up the Modern POS. Just do a login and leave it there for a while.
Step 4 – Get the debugger ready
Go back to Visual Studio, go to the Debug menu and select Attach to process.
Change the code type from automatic to Managed (v4.6, v4.5, v4.0)
Mark Show processes from all users, select the w3wp.exe processes and click Attach.
I know that you probably only need to attach to one of them; but it is much easier just selecting them all.
Take a quick look at your breakpoints to make sure that they are active. If not you might be missing a reference in the commerceruntime file.
Step 5 – Back to the POS to get the debugger activated
What we need to do now is to get the POS to require an instance of the Discount object on the retail server. In this example I add a pair of sunglasses to the basket:
That gets us into the debugger and we can do what we need to do in order to see how it works or start troubleshoot.
I hope this helps you get a bit deeper into the retail server or other services related to the New Dynamics AX.