Using the Reflector API to get decompiled source code

I am looking for some structure that allows decompiling a .NET assembly to get the source code.

I know that Reflector offers some kind of API for performing operations on assemblies, when I used it, it seems that I only return IL instructions and not the actual source code.

What I would like to do is install some kind of smart unhandled exception handler that will give me unsuccessful lines of code (for internal debugging purposes).

Is this possible using the Reflector API? What other tools are available for this purpose?

+4
source share
3 answers

I have written several articles that can help you with this.

http://www.simple-talk.com/dotnet/.net-framework/-.net-reflector-meets-the-codedom/ talks about creating your own language for a reflector to figure out. This is useful for running language structures that the Reflector will invoke.

http://www.simple-talk.com/dotnet/.net-tools/hosting-.net-reflector-in-your-own-application/ talks about the placement of Reflector in your own code for using the API. This will allow you to go through the process of accessing the API in the reflector and gain access to its logic.

I hope this helps at least point you to get what you need.

+3
source

You can take a look at (Open Source) ILSpy . Since they can do what you need, and they also provide source code, you should take this as a starting point.

+2
source

I'm not sure I understand what you need, but if you need information about the runtime where the exception occurred, you can use the StackTrace and StackFrame classes found in the System.Diagnostics namespace to get information from the call stack. But unfortunately, you will not get the source code in clear text.

-1
source

Source: https://habr.com/ru/post/1387941/


All Articles