I'm trying to obfuscate a library with ConfuserEx, but afterwards my app crashes with MissingMethodException with stack trace pointing to first usage of obfuscated class and method in question is the one that was renamed. I have no idea where its call or other usage was found, so it is not clear what should I check. My guess is that exception is happening during JIT process.
Only rename obfuscation was applied and I have map to reverse it.
I looked at obfuscated module and renamed version of the method definitely exists.
Also running PEVerify.exe on obfuscated module gives some errors (only small excerpt is provided below):
[IL]: Error: [d:\1\Confused\my.dll : _YGbNngBKpRxvvy7NkSKSrcvDmJG_::_17w1GiROq6y1aWRw9wWSUGOde1C_][mdToken=0x60003cd] Method does not exist.
Method does not exist.
Method does not exist.
[IL]: Error: [d:\1\Confused\my.dll : _cdMM5QrQwL2ksRGa1UJRmJUkVTd_::.ctor][mdToken=0x60006c8][offset 0x00000002] Unable to resolve token.
[IL]: Error: [d:\1\Confused\my.dll : ClassXyz::_tGtv2dtaIMIA6LoHXu7DwMxfvlS_][mdToken=0x6000732] Method does not exist.
[IL]: Error: [d:\1\Confused\my.dll : ClassXyz::_tk0zK3VXciZeRsH2nVWBZ6jNVdE_][mdToken=0x6000733] Method does not exist.
[IL]: Error: [d:\1\Confused\my.dll : ClassXyz::_tGtv2dtaIMIA6LoHXu7DwMxfvlS_][mdToken=0x6000732] Method does not exist.
[IL]: Error: [d:\1\Confused\my.dll : ClassXyz::_tk0zK3VXciZeRsH2nVWBZ6jNVdE_][mdToken=0x6000733] Method does not exist.
[IL]: Error: [d:\1\Confused\my.dll : ClassXyz::_PkJlSB6sykBdsQ8OXX3CBVEXudk_][mdToken=0x6000735] Method does not exist.
[IL]: Error: [d:\1\Confused\my.dll : ClassXyz::_AYy29oWv1vnvKJP5Q1lcxUcQZRd_][mdToken=0x6000757] Method does not exist.
I'm ready to debug obfuscation process to search what went wrong... but I have no idea what to look for. How can I find out, what part of code is trying to use old method name? How to work with PEVerify's output, e.g. how mdTokens are going to help me?
It just needs patience. First, use WinDbg to launch that application and let the application crash. Then you can see the detailed exception info such as call stack and registers. With some help from tools such as ILSpy you can see exactly which method is missing. Finally analyze the obfuscation log file to find the original method.
Typical workaround is to try to exclude that method from obfuscation to see if the issue is solved. But there might be other workarounds or simply no solution but to fix the obfuscator.
I am the current maintainer of Obfuscar, so above is my personal experience when debugging issues with Obfuscar. Hope it helps you out.