Pregunta

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

I know Reflector offers some sort of API to perform operations on assemblies, when i used it it seems that i only get back IL instructions and not actual source code.

What i would like to do is set some sort of smart unhandled exception handler, that will get me the failing lines of code (for internal debugging purposes).

Is this possible using the Reflector API? what other tools are available to this end?

¿Fue útil?

Solución

I wrote a couple of articles that may be helpful for you in doing this.

http://www.simple-talk.com/dotnet/.net-framework/-.net-reflector-meets-the-codedom/ talks about creating your own language for Reflector to disassmeble to. This is useful for walking language structures that Reflector will throw up to.

http://www.simple-talk.com/dotnet/.net-tools/hosting-.net-reflector-in-your-own-application/ talks about hosting Reflector in your own code to use the API. This will step you through the process of accessing the API in reflector and accessing its logic.

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

Otros consejos

You could take a look at the (Open Source) ILSpy. Since they are able to do what you require and they also provide source code, you should be able to take this as a starting point.

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

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top