Can a C# program find out what language an assembly is written in?

L

Larry__Weiss

Can a C# program find out what language an assembly (or components
thereof) is written in?

- Larry
 
J

Jeroen Mostert

Larry__Weiss said:
Can a C# program find out what language an assembly (or components
thereof) is written in?
All assemblies are written in IL.

Or to put it differently, it's impossible to do this with any sort of
reliability. You can guess at it heuristically: for example, all assemblies
compiled with the C# compiler will have a private "<Module>" class; those
compiled with the VB.NET compiler will not (they have other telltale signs,
like having a class with a StandardModuleAttribute). However, drawing
conclusions from this is dubious at best, and it would be hitting a moving
target.
 
L

Larry__Weiss

Jeroen said:
All assemblies are written in IL.

Or to put it differently, it's impossible to do this with any sort of
reliability. You can guess at it heuristically: for example, all
assemblies compiled with the C# compiler will have a private "<Module>"
class; those compiled with the VB.NET compiler will not (they have other
telltale signs, like having a class with a StandardModuleAttribute).
However, drawing conclusions from this is dubious at best, and it would
be hitting a moving target.

To dig a little deeper, why are there currently those telltale heuristic
differences? Do they indicate any basic differences in what can be
implemented in C# compared to what can be implemented with VB.NET ?

- Larry
 
F

Family Tree Mike

Look at "Reflector" by searching the net. It can dissassemble an exe or dll
to VB, C#, C++, Delphi, Chrome, or show the IL. It isn't directly related
to your question, but, this tool doesn't try and tell me what the language
used for an assembly originally was.
 
T

Tom Dacon

To dig a little deeper, why are there currently those telltale heuristic
differences? Do they indicate any basic differences in what can be
implemented in C# compared to what can be implemented with VB.NET ?

More than anything, the differences simply reflect (no pun intended) the
design choices made by the programmer teams that implemented the languages.

This also applies to certain syntax differences between, say, C# and VB as
the two most well-known languages hosted on top of IL. The designers of VB
gave their users certain kinds of "syntactical sugar" that the C# designers
didn't think of or perhaps didn't think would be useful or worth the
trouble. The C# team, on their side, did the same thing with features that
VB doesn't happen to have (the 'using' statement springs to mind).

Neither of these sets of differences represent limitations of what the
languages could in principle be made to do. IL has quite a bit more
capability than has been exposed in either language.

Tom Dacon
Dacon Software Consulting
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top