Take the 2-minute tour ×

Assembly in .net Framework is, as I understand, intermediate language file + some metadata, manifest and maybe something else.

CLR translates an assembly to the machine code, which can be executed on the given local machine.

That means that assembly shouldn't be executable by the machine before being processed by CLR. If it's so, then why does it have .exe extension, which is executable on Windows machines?

share|improve this question
Edited tags; [assembly] is for assembly-language questions. –  Stephen Canon Mar 29 '11 at 21:06

5 Answers 5

up vote 16 down vote accepted

Since Windows needs to create a process and the first thing .exe will do is to host CLR by loading mscoree.

From CLR via C#:

After Windows has examined the EXE file's header to determine whether to create a 32-bit process, a 64-bit process, or a WoW64 process, Windows loads the x86, x64, or IA64 version of MSCorEE.dll into the process's address space. On an x86 version of Windows, the x86 version of MSCorEE.dll can be found in the C:\Windows\System32 directory. On an x64 or IA64 version of Windows, the x86 version of MSCorEE.dll can be found in the C:\Windows\ SysWow64 directory, whereas the 64-bit version (x64 or IA64) can be found in the C:\Windows\System32 directory (for backward compatibility reasons). Then, the process' primary thread calls a method defined inside MSCorEE.dll. This method initializes the CLR, loads the EXE assembly, and then calls its entry point method (Main). At this point, the managed application is up and running.

share|improve this answer

I have recently written a blog post on the CLR stub in a .NET assembly and how it fits inside the PE file executable format. The whole series can be found here.

Essentially, inside a .NET assembly is a tiny bit of native code that starts the CLR. However, this code only exists for backwards-compatibility. From Windows XP, the OS loader natively knows to load the CLR for executable that have the CLI header in them.

share|improve this answer

A .NET .exe is a special kind of .exe that will first load up the CLR (Common Language Runtime). It will then compile the IL code inside the .exe through the CLR.

An .exe compiled through the .NET framework is a kind of Portable Executable. The .exe has a CLR Header and CLR Data section. When the .exe loads, the OS will yield control to the CLR. The CLR Data section in the .exe has a metadata and an IL (Intermediate Language) segment. The metadata segment contains information about the assembly (such as the assembly manifest). The IL segment contains the code for the program in IL format. This is an intermediate format similar to Java bytecode.

share|improve this answer

Since it's still an EXEcutable.

share|improve this answer
So are .bat, .py, .com, .class etc.. –  Blorgbeard Mar 31 '11 at 10:43
Well, yes. But they are not compiled into IL-code that is invented by Microsoft ;) –  jgauffin Mar 31 '11 at 10:50
Heh, so your answer becomes "because MS said so" :P –  Blorgbeard Mar 31 '11 at 10:55
Yep, but that doesn't sound as witty as Since it's still an EXEcutable. :P –  jgauffin Mar 31 '11 at 11:03
I admit you've got me there :P –  Blorgbeard Mar 31 '11 at 11:05

For a detailed summary of why this works see this article.

share|improve this answer

Your Answer


