0

A colleague complained that the "assembly" I gave him (a regular, non-NET compiled C++ DLL-file) didn't work. I replied "What's... an assembly?".

So by reading this dot net tutorial and this similar SO question my understanding is, that DLL and EXE files (and also executables / shared libraries made in Linux using Mono of course) created by NET are fundamentally different from 'regular' native machine code libraries and executables, because they don't contain native byte code, but rather some strange MSIL (Microsoft Intermediate Language) code as far as I understand.

So I'm asking

  • Why are these .NET MSIL-containing files called assemblies? What do they assemble or what are they assembling?

and also

  • Why didn't Microsoft let those assemblies have different file extensions than native executables / shared libraries? They don't work without a NET-interpreter (or is it called NET-VM?), so why not distinguish them from regular native code?
    I mean Python has .py files, Java has .class / .jar files and so on... This could have prevented some confusion in my case.
nada
  • 2,109
  • 2
  • 16
  • 23
  • 2
    Does this answer your question? [How can I view MSIL / CIL generated by C# compiler? Why is it called assembly?](https://stackoverflow.com/questions/3326571/how-can-i-view-msil-cil-generated-by-c-sharp-compiler-why-is-it-called-assemb) –  Mar 02 '21 at 20:36
  • @DuelTheBearded Authors of the other mentioned languages didn't invent any fancy new term like _assembly_ and also didn't make it look like native compiled code. Why? – nada Mar 02 '21 at 20:39
  • 2
    Because they can contain multiple modules (DLLs or EXEs) but it is common to only have one per assembly, see [this answer](https://stackoverflow.com/a/3327167/14868997) on the linked question. And MSIL isn't strange, it's been around for 20 years, and the concept was first done by Java even earlier – Charlieface Mar 02 '21 at 20:46
  • I'm getting the feeling only NET devs are reading this question and are too far inside to extract the core of what I'm asking... Or maybe I didn't ask clearly enough. – nada Mar 02 '21 at 20:54
  • You didn't ask clearly. If you want to know what/why is called "assemblies", the linked thread answered it. If you want to know why the old extensions (.exe/.dll) are used, post a new question instead. – Lex Li Mar 02 '21 at 21:29

1 Answers1

0

.NET languages (C#, VB, F#) are transpiled into an intermediate language called the Common Intermediate Language (CIL), which was previously called the Microsoft Intermediate Language (MSIL). When you open a .NET executable, it is running in a virtual machine, which converts the CIL code into Assembly on the fly. This is commonly called JIT-compiling.
Assemblies are CIL and metadata files generated by the .NET compiler, along with any resources you include into your project, compressed into one file. This is why you cannot use a native assembly with a .NET assembly. They are totally different things. A native assembly, from my limited knowledge, is Assembly code, resources the programmer included, and, depending on the language, metadata.
As for why Microsoft let those assemblies have the same name as native assemblies, what is the point in having new file extensions? Also, Python is an interpreted language, meaning there is no compiling. It cannot be compiled into an assembly.

I hope that clears it up! Also, next time, please search for the answer to your question before asking. I found a similar question with a quick Google search.

  • Yes, but my question is not about what assemblies are, but why they're called like that and don't have a separate file extension like Python or Java _assemblies_. Yes, why don't we call .py and .class / .jar flies _assemblies_ too then? – nada Mar 02 '21 at 20:23
  • Microsoft just didn't see any point in changing the terminology. It was simpler to keep the terminology that programmers are used to. Many C# developers are also C/C++ developers. –  Mar 02 '21 at 20:25
  • What terminology are you referring to? – nada Mar 02 '21 at 20:26
  • Assemblies, shared libraries, dynamically-linked libraries, executables, etc. –  Mar 02 '21 at 20:27
  • Here is a Wikipedia link: https://en.wikipedia.org/wiki/Assembly_(CLI) –  Mar 02 '21 at 20:33
  • Yes, so far so good, but that still doesn't answer why it's called an _assembly_. Again, authors of the other mentioned languages didn't invent any fancy new term like _assembly_ and didn't make it look like native compiled code. – nada Mar 02 '21 at 20:37
  • .NET uses the term 'assembly' because: (1) other common languages use it, so it is a familiar term for many developers (2) that is what it is: it is CIL files and metadata assembled into one file that can be read by their VM/compiler. –  Mar 02 '21 at 20:39
  • You say _Other common language use it_. Please give an example where that term is used outside of NET with the same meaning as in NET. – nada Mar 02 '21 at 20:43
  • C/C++ use the term 'assembly'. –  Mar 02 '21 at 20:44
  • Yes, assembly as in inline `asm` for example, but that is something completely different. – nada Mar 02 '21 at 20:52
  • Look, they call it assemblies because (1) it is CIL source code and metadata assembled into a form readable by the VM/compiler (2) CIL is also called .NET Assembly (3) it is a term used in other languages (4) it is a common term to describe both DLL's and EXE's, which are the same thing to the .NET compiler. –  Mar 02 '21 at 20:56