samira riazati
samira riazati

Reputation: 525

.NET Portable Executable File VS .NET Assembly

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?

Upvotes: 2

Views: 2759

Answers (3)

M.A. Hanin
M.A. Hanin

Reputation: 8074

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.

Upvotes: 1

Lex Li
Lex Li

Reputation: 63123

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.

Upvotes: 2

Blindy
Blindy

Reputation: 67352

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.

Upvotes: 2

Related Questions