What exactly is an Assembly in C# or .NET?

2020-02-07 14:28发布

Could you please explain what is an Assembly in C# or .NET?

  1. Where does it begin and where does it end?
  2. What important information should I know about Assemblies?

9条回答
仙女界的扛把子
2楼-- · 2020-02-07 14:37

Here's another explanation of the make up of .NET Assemblies, a mini-quote:

The .NET framework consists of the concepts of modules, assemblies, which both store metadata and manifest information. An assembly can contain multiple modules. Visual C# only ever creates one module which is turned into an assembly by the C# compiler (csc.exe), but an assembly can link many .NET modules together via the assembly linker (al.exe) command line tool. For example each of your source code .cs files could be compiled into a module and linked together to form an assembly - an assembly is just a collection of modules and resources. One of these modules however must contain manifest metadata (see below) information for the assembly to be understood by the CLR.
....
Having created a new .exe or .dll inside VS.NET you see your file appear inside your bin folder. Opening it in notepad will give out gibberish, or even inside a hexadecimal editor without knowing the structure of the file, you need a tool like ildasm.exe or CFF explorer to make meaning from it. The structure of the assembly is is as follows:

PE header
CLR header
CLR metadata
CLR
IL code
Native data

查看更多
淡お忘
3楼-- · 2020-02-07 14:38

The answer is in order for immediate-grasping.

Put simply, it is the compiled project involving your classes and additional files, if there are. That is, each project in a solution is assembly.

Or more techinally,

An assembly is where a type is stored in the flesystem. Assemblies are a mechanism for deploying code. For example, the System.Data.dll assembly contains types for managing data. To use types in other assemblies, they must be referenced. - Source

How do we know it? If you glance at properties of a project under the solution you can see the following images.

When you compile the project, it turns out to DLL or EXE.

enter image description here enter image description here enter image description here

查看更多
The star\"
4楼-- · 2020-02-07 14:44

An Assembly is a collection of logical units. Logical units refer to the types and resources which are required to build an application and deploy them using the .Net framework. Basically, Assembly is a collection of Exe and DLLs. It is portable and executable.

查看更多
劫难
5楼-- · 2020-02-07 14:48

After writing source code of your program(project) then a file is created which may be DLL or EXE depends on your project. It makes only once for a single project. It has two types 1:- single 2:- shared or multiprogram single assembly used only in a single program while shared can be used for multiprogram

查看更多
该账号已被封号
6楼-- · 2020-02-07 14:51

http://www.codeguru.com/columns/csharp_learning/article.php/c5845

An assembly is a file that is automatically generated by the compiler upon successful compilation of every .NET application. It can be either a Dynamic Link Library or an executable file. It is generated only once for an application and upon each subsequent compilation the assembly gets updated.

查看更多
够拽才男人
7楼-- · 2020-02-07 14:53

An assembly is a DLL or an EXE which will be created when you publish it or compile your application.

查看更多
登录 后发表回答