Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Types of assembly - whats the difference

Whats is the difference between static and dynamic assembly. Only that fact that one can be loaded from file and another can be created during programm running?

like image 201
hbk Avatar asked Nov 22 '13 19:11

hbk


1 Answers

Static assemblies can include .NET Framework types (interfaces and classes), as well as resources for the assembly (bitmaps, JPEG files, resource files, and so on). Static assemblies are stored on disk in portable executable (PE) files. You can also use the .NET Framework to create dynamic assemblies, which are run directly from memory and are not saved to disk before execution. You can save dynamic assemblies to disk after they have executed.

Static Assemblies are those Assemblies which are stored on the disk permanently. They may include .NET Framework classes, interfaces as well as resource file. These assemblies are not loaded directly from the memory instead they are directly loaded from the disk when CLR (Common Language RunTime) requests for them. These Assemblies used to store on the disk as a file or set of file. Whenever one compiles the C# code, one gets STATIC assemblies.

Dynamic assemblies are those assemblies which are not stored on the disk before execution in fact after execution they get stored on the disk. When .NET runtime calls them they are directly loaded from the memory not from the disk. Reflection emit provides many ways to create dynamic assemblies means These are created in the memory using System.Reflection.emit namespace.The System.Reflection.Emit namespace contains classes that allow a compiler or tool to emit metadata and Microsoft intermediate language (MSIL) and optionally generate a PE file on disk. When an application requires the types within these assemblies these dynamic assemblies are created dynamically at run time

In simple words the Static assemblies the normal assemblies which we are daily interacting with it load resolve it etc. and the Dynamic the assemblies which you are create it with reflection and invoking.

Information sources: http://www.dotnetheaven.com/article/static-assembly-vs-dynamic-assembly-in-csharp and MSDN

like image 151
Bassam Alugili Avatar answered Nov 12 '22 12:11

Bassam Alugili