Decompiled assembly, which programming language was used

好久不见. 提交于 2019-12-11 23:56:10

问题


How would you know if a decompiled assembly was written in C# or VB.net?


回答1:


I am not aware of any explicit "I was compiled with..." information in the manifest / attributes. You could perhaps use feature detection (in particular, things like how anonymous types are implemented, and module-level methods), but:

  • in most cases it shouldn't matter
  • compilers you don't know about could appear similar, giving you false answers
  • not all IL comes from a compiler; it could be assembled from raw IL, either with IL as the source-language, or via meta-programming techniques

Personally, I would strongly advise avoiding any dependency on source language




回答2:


I vaguely remember there being a utility assembly which was referenced automatically in VB projects, but not C# projects. I'm talking .net 1.1 era (Visual Studio 2003). It made accessing parts of the Explorer shell very easy. I've been looking but have not been able to find it (will edit if I can remember what it was). It may have been obsoleted/dropped in later Visual Studios, but that would be a very strong indicator for original VB (thought C# assemblies could also reference it).

Edit: As Hans noted in his comment the assembly is Microsoft.VisualBasic.

Other than that, it is probably doable by finding patterns of IL used by the different versions of C# vs VB compilers to compile different common language constructs.

If all you want is to see an approximation of the source code for compiled assemblies. .Net decompilers such as ILSpy, .Net Reflector or dotPeek do a pretty good job if the original assembly was not obfuscated.



来源:https://stackoverflow.com/questions/16418080/decompiled-assembly-which-programming-language-was-used

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!