How to debug Acumatica with dnSpy

Hello everybody,

today I want to share with you few words about debugging of Acumatica. There are plenty of wonderful posts for doing this with help of already provided PDB files of existing graphs and first of all I definetely recommend to use them.

But there are scenarios when default pdb provided is not enough. One of recent examples when I faced it was debugging of web api rest calls. 

Below I'll provide you with steps, which you can accomplish in order to debug error stack trace like this ( screenshot from postman ):

how many times in your life you looked on it and said: I'd like to debug that code, but I don't have source code! What will be next steps? Open case in Acumatica, provide them with reproducable customization, 

and slowly but gradually solve the problem. 

Let me introduce to you tool dnSpy. With it's help, you can debug source code of Acumatica, which is not available for you by default. Below goes steps, necessary for debugging class 

PX.Api.ContractBased.EntityService and it's method GetOperationResult.

1. Download source code of  dnSpy and build it.

2. Execute dnSpy.exe

3. Send Post request to your Acumatica instance for example in Postman similar to this: https://localhost/PaymentSystem/entity/auth/login

4. In menu of dnSpy choose Debug -> Attach to Process like on screenshot:

5. Find your instance of w3wp of Acumatica. It can look similar to next screenshot:

6. Go to tab modules, and find there module PX.API.ContractBased:

7. Now will be turn of Assembly Explorer. In this window find class EntityService. It lives under PX.API.ContractBased -> PX.Api.ContractBased -> EntityService -> GetOperationResult, and set breakpoint there like on screenshot:

8. You are all set. Execute call in postman one more time, and you'll get caught in dnSpy debugger:


With all of this I just want to add the following. You'll be able to follow the code, but because Acumatica dll's are optimized, your's debugging experience will be limited with following steps, but not always seeing what are values of local variables.

That is serious limitation of dnSpy for debugging Acumatica. 

Here  dnSpy describes how to make images debuggable. I wasn't able to make it debuggable because of assembly linker error, but that will be part of another story. I hope that I'll find some time to dig into it and join dnSpy with Assembly Linker.

No Comments

Add a Comment