This started as a way to find C++/CLI and Managed C++ assemblies so that all classes internal to them could be tested to ensure all inherited methods were being reimplemented. I would like to add this as a build process step to ensure that it never happens again.
Thinking about this problem also made me a bit curious as it would be interesting to be able to determine any .NET language used. Because of this, I went a bit further and compared assemblies from all of the .NET languages. So far here is what I've found through a small program I wrote which compares the type and attribute data from any set of .NET assemblies via reflection:
It might be reasonable to parse in this order:
However, as this is a horrible hack, I wanted to check in here to make sure that there wasn't another option available.
NET Framework, assemblies can contain one or more modules. This allows larger projects to be planned so that several developers can work on separate source code files or modules, which are combined to create a single assembly. For more information about modules, see How to: Build a multifile assembly.
Call the GetMetadataReader method on the PE reader instance to create a metadata reader. Check the value of the IsAssembly property. If the value is true , the file is an assembly.
. NET defines a binary file format, assembly, that is used to fully describe and contain . NET programs. Assemblies are used for the programs themselves as well as any dependent libraries.
These are all stored in the GAC at %WINDIR%\assembly , which you can view in Windows Explorer. The actual dlls can be found in subfolders of the GAC , GAC_32 , and GAC_MSIL folders, seemingly dependent on their version.
Checking the references for things like the VB or F# class libraries seems to be the least shaky way to do this, but as others mention, it's a heuristic - just like there's no definitive way to tell which language a native binary is written in (but you can be almost 100% sure by heuristics)
When a .NET language is compiled, all you get is IL. I am not aware of a standard way of determining which specific language created the assembly. You can take an existing assembly and ildasm (disassemble) it into IL and them ilasm (assemble) it back into a virtually identical assembly.
The heuristics you use is a reasonable and clever way to identify the language used to create the assembly. However, bear in mind that these details might change between compiler versions of the languages.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With