0

I would like to identify the language(C#, VB, whatever) used to create a particular assembly.

I would also like to identify the compiler (the MS one, mono).

There doesn't seem to be any information in the assembly. The section about the headers of an assembly in Ecma-335 partition II doesn't mention anything useful.

I wonder if there are fingerprints in an assembly that could reveal that "aha this is something very particular to C#/the c# compiler, you were written in C#!"

This would be useful to know for the static analysis tool I'm writing.

Monkeyget
  • 171
  • 6
  • 1
    I know this has been asked before, but cant find the question. – Stefan Jul 31 '10 at 14:48
  • 1
    In the assembly, all you'll see is MSIL (Microsoft Intermediate Language) - I don't think there's any documented way to find out what language created that MSIL, really (other than looking for specific patterns that you know C# or VB.NET or F# or whatever creates that differentiates them from the other languages) – marc_s Jul 31 '10 at 14:49
  • 4
    Plus: **why** do you need this, really?? What are you trying to accomplish with this?? – marc_s Jul 31 '10 at 14:49
  • possible duplicate of [Determine source language from a binary?](http://stackoverflow.com/questions/1704202/determine-source-language-from-a-binary) – Stefan Jul 31 '10 at 14:50
  • I assume the distinction seen in VS.NET debugging (in stack traces before actually opening the code) is from the pdb files. – Mark Hurd Jul 31 '10 at 15:28
  • I believe there is a better duplicate than the one Stephan found. This question was asked repeatedly very early in the sites history. – dmckee --- ex-moderator kitten Aug 02 '10 at 03:43

1 Answers1

1

This is by design, an assembly stores metadata and IL, information that's language neutral. So that you can easily mix and match code written in different languages. Very nice .NET feature.

The are hints though. A VB.NET programmer is likely to use VB.NET specific language features that are implemented in a helper assembly in the .NET framework. Like the My namespace and conversion operators like CType. Open the assembly with Ildasm.exe and look at the manifest for the .assembly directives. If you see one for Microsoft.VisualBasic then the odds are very high that this was written in VB.NET. If it is missing then good odds for C#, although not conclusive. If you look at the class list and see <CppImplementationDetails> at the top then you know for sure it was written in C++/CLI.

Make sure you don't actually care about this.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536