I'm confused. in some articles I've read PE is an assembly and IL code stores in PE.
In others, I've read PE have an associated assembly manifest and IL code stores in PE. in some articles, I've read IL stores in assembly, and also in CLR header section of PE file stores the information to indicate that PE file is a .NET executable.
PE file and .NET assembly are same or not?
where does the IL code store?

- 38,414
- 7
- 81
- 112

- 515
- 7
- 21
3 Answers
I don't understand the distinction you see, I would reply "yes" to all of them.
More specifically, what you call a PE executable, the typical Windows executable, contains a stub that boots up the .NET VM and a section that contains the compiled assembly code to pass to the VM.

- 65,249
- 10
- 91
- 131
PE is a file format, an envelope, for both native and .NET executable,
https://en.wikipedia.org/wiki/Portable_Executable
A .NET assembly must be a PE, but the reverse is not true.

- 60,503
- 9
- 116
- 147
-
Is this not contradicting the accepted answer, according to which a .NET assembly could just be in memory, and not an actual physical file, and so it's not necessarily a PE ? – John P Feb 29 '20 at 16:25
Think of an assembly as a "logical" concept. The assembly contains IL code, as well as other kinds of data: resources, metadata, versioning information etc.
DLLs and EXE files are a "physical" concept residing in a file system. These files had all sorts of formats throughout history, and PE is one of those formats.
An assembly is usually stored in a DLL or EXE, but doesn't have to: assemblies can be emitted into and loaded from memory, without any physical (file-system) manifestation.
A DLL can actually contain more than one assembly, though that is not the common case.
An assembly is further divided into modules. Modules contain classes. Usually there is just one module inside a given assembly.

- 1
- 1

- 8,044
- 33
- 51
-
"A DLL can actually contain more than one assembly" seems misleading to me, while while an assembly may contain dlls as embedded resources, I don't think that's what most people will think when they read it. The assembly is defined by it's assembly manifest, there is no way for a module (dll, exe, netmodule) to contain more than one distinct assembly manifest and the specification prohibits an assembly from having more than one module with an assembly manifest.. – Brian Reichle Sep 13 '15 at 22:05