4

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?

4
  • 1
    what did you find when you searched? Commented Dec 25, 2011 at 15:40
  • I am not sure i understood your question -- searched what? Commented Dec 25, 2011 at 16:04
  • Do you really want a framework? There are tools out there to do that (ILSpy/Reflector can do it too). However, if the code is obfuscated, it's another story. Commented Dec 25, 2011 at 16:51
  • I would like some API to call from within our app. Commented Dec 25, 2011 at 18:21

3 Answers 3

3

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.

Sign up to request clarification or add additional context in comments.

Comments

2

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.

1 Comment

Is this not possible to do at all with the Reflector API? i will check out ILSpy.
-1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.