简体   繁体   English

使用Reflector API获取反编译的源代码

[英]Using the Reflector API to get decompiled source code

I am looking for some framework that allows decompiling a .NET assembly to get the source code. 我正在寻找一些允许反编译.NET程序集以获取源代码的框架。

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. 我知道Reflector提供某种API来对程序集执行操作,当我使用它时,似乎我只回到IL指令而不是实际的源代码。

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? 这可能使用Reflector API吗? what other tools are available to this end? 为此目的还有哪些其他工具?

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. http://www.simple-talk.com/dotnet/.net-framework/-.net-reflector-meets-the-codedom/谈论为Reflector创建自己的语言以使其无法解析。 This is useful for walking language structures that Reflector will throw up to. 这对于Reflector将要使用的步行语言结构非常有用。

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. http://www.simple-talk.com/dotnet/.net-tools/hosting-.net-reflector-in-your-own-application/谈论在您自己的代码中托管Reflector以使用API​​。 This will step you through the process of accessing the API in reflector and accessing its logic. 这将引导您完成在反射器中访问API并访问其逻辑的过程。

I hope this helps at least point you in the direction to get what you need. 我希望这有助于至少指出你的方向来获得你需要的东西。

You could take a look at the (Open Source) ILSpy . 你可以看看(开源) 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. 我不确定我理解你需要什么,但如果你想获得有关异常发生位置的运行时信息,你可以使用System.Diagnostics命名空间中的StackTraceStackFrame类来从调用堆栈中检索信息。 But unfortunately, you will not get the source code in clear text. 但不幸的是,您不会以明文形式获取源代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM