SlideShare ist ein Scribd-Unternehmen logo
1 von 70
Building Blocks of .NET
      Framework
Agenda
               1. Introduction.
               2. What is Assembly?
               3. Features of Assembly.
               4. Benefits of Assembly.
               5. Contents of Assembly.
               6. Strong Name.
               7. Use Of Strong Name.
               8. Delay Signing.
               9. Categories of Assemblies.
                  a. Single-File Assembly

KolkataGeeks                            2
Agenda (Contd..)
               9 b. Multi-File Assembly
                  c. Private Assembly
                  d. Shared Assembly
               10. How to install assembly in the GAC.
               11. How to remove assembly from the GAC.
               12. How to view the contents of assembly?
               13. Memory Management.
               14. Conditions for a Garbage Collection.
               15. Managed Heap.
               16. Functions Used By Garbage Collector.


KolkataGeeks                           3
Agenda (Contd..)
               17. Phases of Garbage Collection.
               18. Finalize Method.
               19. Dispose Method.
               20. Assembly Manifest.
               21. Contents of Manifest.
               22. Functions of Manifest.
               23. Entry Point
               24. Friend Assembly.
               25. InternalsVisibleTo
               26. GAC & Versioning.


KolkataGeeks                            4
Assembly


               Assemblies are the building blocks of .NET Framework
               applications; they form the fundamental unit of
               deployment, version control, reuse, activation
               scoping, and security permissions.
               Assembly is a packet and it contains program and
               libraries for .NET . It can be used by any program that
               requires the functionality provided by the assembly.


KolkataGeeks                             5
Versioning - Grouping of modules on the basis of same
               version information.
               Deployment - To group code modules and resources that
               support our model of deployment.
               Reuse - Modules can be grouped if they can be logically
               used together for some purpose. For example, if we intend
               to share our assembly with multiple application, then such
               assemblies should be grouped together and signed with a
               strong name.
               Security - Group modules on the basis of same security
               permissions.
               Scoping - Group modules containing types whose visibility
               should be restricted to the same assembly.

KolkataGeeks                              6
Assembly is basically collection of exe or dll files
               which are generated upon successful compilation of
               the .Net application.
               Assemblies can contain one or more modules.




KolkataGeeks                           7
Features of Assembly
      Assemblies are implemented as .exe or .dll
      We can share an assembly by storing it in Global Assembly
      Cache.
      Assembly must be assigned strong named, before placing in
      the Global Assembly Cache.
      On requirement only, assembly are loaded into memory.
      Using reflection, we can obtain information about assembly.




KolkataGeeks                      8
Benefits


               Assemblies are designed to simplify application
               deployment and to solve versioning problems that
               can occur with component-based applications.




KolkataGeeks                           9
Solve Versioning Problems


               Every assembly has a 128-bit version number. This
               version number is presented as a set of four decimal
               pieces: Major.Minor.Build.Revision
               An assembly will use types from the same
               assembly(name and version) from which it was built
               and tested. This use of both name and version to
               identify referenced assemblies avoids the "DLL Hell"
               problem.

KolkataGeeks                           10
Simplify Application Deployment
               Assemblies are the natural unit of deployment. The
               Windows Installer Service 2.0 can install individual
               assemblies as part of a larger setup program. You can
               also deploy assemblies in other ways, including by a
               simple xcopy to the target system.




KolkataGeeks                            11
Contents Of Assemblies

               Generally, a static assembly consists of 4 elements:
               1. Assembly Manifest
               2. Type Metadata
               3. MSIL
               4.Resources




KolkataGeeks                             12
Assembly Manifest

               Assembly Manifest contains assembly metadata. It
               contains all the metadata which are required to
               specify the assembly's version requirements, security
               identity, scope of the assembly and references to
               resources and classes.




KolkataGeeks                            13
It contains Assembly name, Version number, Culture,
               Strong name information , list of all files in the
               assembly, type reference information , information on
               referenced assemblies.




KolkataGeeks                            14
Assembly Metadata


               Metadata is data which contains a detailed
               description of each type, attribute within the
               assembly. We can say, it is a collection of data that
               describes how the elements in the assembly relate to
               each other. Assembly manifest contains this assembly
               metadata.




KolkataGeeks                            15
MSIL

               MSIL is an intermediate language generated by the
               compiler. All .NET assemblies are represented in MSIL.
               Microsoft Intermediate Language (MSIL) is a language
               used as the output of a number of compilers (C#, VB, .NET,
               and so forth).
               The ILDasm (Intermediate Language Disassembler)
               program that ships with the .NET Framework SDK
               (FrameworkSDKBinildasm.exe) allows the user to see
               MSIL code in human-readable format. By using this utility,
               we can open any .NET executable file (EXE or DLL) and see
               MSIL code.

KolkataGeeks                              16
The ILAsm program (Intermediate Language
               Assembler) generates an executable file from the
               MSIL language. We can find this program in the
               C:WINDOWSMicrosoft.NETFrameworkv4.0.30319.




KolkataGeeks                          17
Creation of MSIL
                    Source Code



                          Compiles
                                            Compiler




                       MSIL

                          Converts Into
                                          JIT Debugger



                   Native Code
KolkataGeeks             18
Resource


               Includes the resource files for the application.




KolkataGeeks                             19
Strong Name


               Strong names are cryptographic signature, which can
               be assigned to assemblies. It makes the assembly
               name unique.




KolkataGeeks                           20
Strong-Name


               An assemblies identity – its name, version number
               and public/private key are contained in the strong
               name.
               Assemblies name is unique because of its strong
               name. To sign an assembly with a strong name, we
               have to use sn.exe utility.
               Here sn.exe is the strong name generator.


KolkataGeeks                          21
Strong name adds two bits of metadata to the
               manifest:
               First one is the unique number which belongs to the
               authors of the assembly.
               And the second one is a signed hash of the assembly,
               which proves that the unique number holder has
               produced the assembly. This requires a private/public
               key pair. The public key provides the unique
               identifying number, and the private key helps in
               signing.

KolkataGeeks                           22
Use of Strong Name


               1. Versioning
               2. Authentication
               Versioning solves known problem called as "DLL hell".
               Signed assemblies are unique and SN solves problem
               with namespace collisions .(assembly with the same
               file name can be distributed by the developers).
               Assemblies signed with SNs are uniquely identified
               and are protected.

KolkataGeeks                            23
SN also help developers to uniquely identify versions
               of their .NET assemblies.
               Assemblies in the GAC (Global Assembly Cache) must
               be signed to separate each publisher's namespace
               and to separate each version.




KolkataGeeks                            24
The second important feature of Strong Names is
               authentication; a process where we want to ensure
               ourselves about the code's origin.
               On adding a strong name, the CLR is allowed to
               perform verification when the assembly is loaded to
               determine that it has not been tampered with since it
               was compiled.




KolkataGeeks                           25
The same situation is when SNs are used. You can
               remove SNs from assemblies , but this makes no
               sense because just as in the case of emails, assemblies
               without SNs can't be trusted when environment is set
               up to require those digital signatures or SNs.




KolkataGeeks                            26
While developing an application that has a strong
               name, all libraries it uses must also have a strong
               name. We cannot refer to an assembly without a
               strong name from an assembly with a strong name.




KolkataGeeks                           27
Delay Signing

               We might want to restrict access to the key pairs used
               for signing assemblies.
               The reasons is, if a key-pair is leaked, assembly is
               tamperable.
               Again if key pairs are not given to the
               developers, they cannot compile and test assemblies
               with their correct identity. This critical problem can be
               resolved using ‘Delay Signing’.



KolkataGeeks                             28
A delay signed assembly contains the public key and
               not the private key. The developer instructs the CLR,
               to bypass the validation for the delay-sign assemblies.
               At the time of final deployment, the private key
               holder re-signs the assembly with the real key pair.




KolkataGeeks                            29
Delay Sign


               If we specify to delay sign the assembly, the compiler
               in that case, does not sign the assembly. We will also
               discover that the runtime considers the assembly to
               be invalid and will not load it or allow us to debug and
               run it.




KolkataGeeks                             30
Steps for Delay Signing
               1. Create a key pair
               Sn –k mykey.snk
               2. Separate the public and the private key. Extract the
               public key and keep it in its own file.
               Sn –k mykey.snk myPublicKey.snk
               3. Place the details in the AssemblyInfo.cs
               <assembly:AssemblyKeyFileAttribute("myPublicKey.snk")>
               <assembly:AssemblyDelaySignAttribute(true)>
               4. To skip the signature verification for the assembly
               sn -Vr mydll.dll


KolkataGeeks                                  31
5. Just before shipping, the signing authority of the
               company, signs with the actual strong name using –R
               option of the Strong Name tool.
               sn -R mydll.dll Testkey.snk




KolkataGeeks                            32
Categories of Assemblies




KolkataGeeks              33
KolkataGeeks   34
Single-File Assembly


               We can group all elements of an assembly in a single
               physical file.




KolkataGeeks                            35
Single File Assembly


                  SingleFileAssembly.dll
                                             Assembly
                                             Manifest

                                           Type Metadata

                                                 MSIL

                                             Resources

KolkataGeeks                                36
Modules


               Modules are the containers, which holds the contents
               of an assembly. A module corresponds to a file,
               containing the contents of an assembly.
               This extra containership is helpful in case where
               assembly contains multiple files.




KolkataGeeks                           37
MultiFile Assembly
               We can create a multifile assembly from several code
               modules and resource files.
               The elements of an assembly can be contained in
               several files.
               Modules of compiled code(.netmodule) and
               resources(.bmp), or other files required by the
               application, can be put together to make a multifile
               assembly.




KolkataGeeks                            38
In a multi-file assembly, the main module, always
               contains the manifest; additional modules can contain
               IL and /or resources. The manifest describes the
               relative location of all the other modules that make
               up the assembly.




KolkataGeeks                           39
Multi-File Assembly

         MultiFile.dll
                                 Util.netmodule


                                 • Type Metadata
         • Assembly Manifest     • MSIL Code
         • Type Metadata
         • MSIL Code


                                  Graphic.bmp


                                   • Resources

KolkataGeeks                      40
Here all the three files belong to an assembly.
               Util.netmodule is compiled as a separate module. And
               it contains no manifest. When the assembly was
               created, assembly manifest was added to the
               multifile.dll. This manifest indicates its relationship
               with util.netmodule and graphic.bmp.




KolkataGeeks                            41
How to create mulifile assembly




KolkataGeeks           42
The module parameter with the /t compiler option
               indicates that the file should be compiled as a
               module. With the following command, a module
               named Class1.netmodule is created, which can be
               added to an assembly.




KolkataGeeks                         43
Now we have to compile modules with respect to
               other modules. So let’s write the code first:




KolkataGeeks                          44
KolkataGeeks   45
/t:module is used to create a module, which can be
               added to an assembly in future.
               /addmodule: is used to reference a namespace
               created in Class1.netmodule.
               The compiler produces a module called
               MainClient.netmodule that contains a reference to
               another module, Class1.netmodule.




KolkataGeeks                            46
Creating a multifile assembly
           Class1.netmodule and MainClient.netmodule are included
           in the assembly.
           The /main: option specifies the assembly’s entry point.
           The /out: option specifies the name of the output file,
           which will contain the assembly metadata.
           /target: option specifies the assembly file type.




KolkataGeeks                         47
Multifile Assembly Created




KolkataGeeks               48
KolkataGeeks   49
Private Assemblies



               Assemblies which are used for each application
               separately. On creation of an assembly, it is private by
               default. This type of assembly cannot be used by any
               other application, until and unless this assembly is
               copied separately in the respective application’s
               folder.


KolkataGeeks                             50
Let us create a ClassLibrary. Then we are going to
                     build it. After building, .dll is created.


KolkataGeeks                             51
Now we can find that really, .dll file has been created in the bin
     folder. Now we want to use this .dll in our new console application.




KolkataGeeks                          52
Now I have created my application.
    Added the .dll by References->Browse. And as we can see, I have
    also used the ClassLibrary1 on the top.




KolkataGeeks                        53
This is the output. And it shows that the use of private
                                      assembly.




KolkataGeeks                              54
Separate copy of ClassLibrary1.dll has been copied here. So
                         this is Private Assembly.




KolkataGeeks                         55
Shared Assembly
               Shared assembly can be used in situations where it is
               not necessary to install a version of an assembly for
               each application that uses it.




KolkataGeeks                            56
Shared Assembly


               To make a shared assembly, we require it to store in
               Global Assembly Cache GAC. GAC is reserved for
               storing assemblies and for sharing them in between
               different applications.
               Here every assembly must have an unique name. So
               we need to assign strong name to assemblies before
               storing it in the GAC.


KolkataGeeks                           57
Pictorial representaion of Shared Assembly


                                     Application1




                                       GAC
                     Application4                   Application2
                                     (shared
                                    assembly)



                                     Application3




KolkataGeeks                             58
Each assembly is assigned a strong name.




                Assigning Strong Name
KolkataGeeks                           59
Adding .dll in the GAC


               How to install .dll into GAC




KolkataGeeks                             60
Location of Shared Assembly




               Here our shared assembly is located.




KolkataGeeks                            61
Using Shared Assembly




KolkataGeeks             62
Here no separate copy of assembly is pasted in the
               ConsoleApplication3bindebug folder. Instead here
               the shared assembly from the GAC has been used.




          Common Copy of Shared Assembly has been used
                             here.

KolkataGeeks                           63
Remove an assembly from GAC
               We have to use Global Assembly Cache
               tool(gacutil.exe) to remove an assembly from the
               GAC.
               Syntax:
               At the Command prompt:
               Gacutil /u assemblyname
               Here /u means uninstall.
               And assemblyname is the name of the assembly,
               which we want to remove from the GAC.


KolkataGeeks                           64
View the contents of assembly


               Let’s write some code and compile it.
               Assembly will be created.
               Type a command ildasm from the command prompt.
               An application will be open, name Intermediate
               Language Disassembler.
               This application opens our assembly and shows all
               classes, methods , data fields, global and local
               application data.

KolkataGeeks                          65
To view the contents of a manifest for a particular
               assembly, we can use the ILDassembler(ILDasm.exe),
               which is part of the .NET Framework SDK.




KolkataGeeks                          66
KolkataGeeks   67
Type ildasm




KolkataGeeks        68
Ildasm window opens. File->Open->Browse for our .dll
               file.




KolkataGeeks                           69
KolkataGeeks   70

Weitere ähnliche Inhalte

Was ist angesagt?

.NET TECHNOLOGIES
.NET TECHNOLOGIES.NET TECHNOLOGIES
.NET TECHNOLOGIESProf Ansari
 
.Net framework interview questions
.Net framework interview questions.Net framework interview questions
.Net framework interview questionsMir Majid
 
Docker Security
Docker SecurityDocker Security
Docker SecurityBladE0341
 
Inside .net framework
Inside .net frameworkInside .net framework
Inside .net frameworkFaisal Aziz
 
Docker - the what why and hows
Docker - the what why and howsDocker - the what why and hows
Docker - the what why and howsSouvik Maji
 
Frankenstein's IDE: NetBeans and OSGi
Frankenstein's IDE: NetBeans and OSGiFrankenstein's IDE: NetBeans and OSGi
Frankenstein's IDE: NetBeans and OSGiToni Epple
 
OCI Image Spec
OCI Image SpecOCI Image Spec
OCI Image Specstrikr .
 
.NET Core, ASP.NET Core Course, Session 5
.NET Core, ASP.NET Core Course, Session 5.NET Core, ASP.NET Core Course, Session 5
.NET Core, ASP.NET Core Course, Session 5aminmesbahi
 
Embedding Linux For An Automotive Environment
Embedding Linux For An Automotive EnvironmentEmbedding Linux For An Automotive Environment
Embedding Linux For An Automotive EnvironmentFSCONS
 
Linux container & docker
Linux container & dockerLinux container & docker
Linux container & dockerejlp12
 
An operational view into docker registry with scalability, access control and...
An operational view into docker registry with scalability, access control and...An operational view into docker registry with scalability, access control and...
An operational view into docker registry with scalability, access control and...Conference Papers
 
Dockercon EU 2015 Recap
Dockercon EU 2015 RecapDockercon EU 2015 Recap
Dockercon EU 2015 RecapLee Calcote
 
Diving Through The Layers: Investigating runc, containerd, and the Docker eng...
Diving Through The Layers: Investigating runc, containerd, and the Docker eng...Diving Through The Layers: Investigating runc, containerd, and the Docker eng...
Diving Through The Layers: Investigating runc, containerd, and the Docker eng...Phil Estes
 
Native development kit (ndk) introduction
Native development kit (ndk)  introductionNative development kit (ndk)  introduction
Native development kit (ndk) introductionRakesh Jha
 

Was ist angesagt? (20)

PIC your malware
PIC your malwarePIC your malware
PIC your malware
 
.NET TECHNOLOGIES
.NET TECHNOLOGIES.NET TECHNOLOGIES
.NET TECHNOLOGIES
 
.Net framework interview questions
.Net framework interview questions.Net framework interview questions
.Net framework interview questions
 
Docker Security
Docker SecurityDocker Security
Docker Security
 
Inside .net framework
Inside .net frameworkInside .net framework
Inside .net framework
 
Net framework
Net frameworkNet framework
Net framework
 
Docker - the what why and hows
Docker - the what why and howsDocker - the what why and hows
Docker - the what why and hows
 
Frankenstein's IDE: NetBeans and OSGi
Frankenstein's IDE: NetBeans and OSGiFrankenstein's IDE: NetBeans and OSGi
Frankenstein's IDE: NetBeans and OSGi
 
OCI Image Spec
OCI Image SpecOCI Image Spec
OCI Image Spec
 
Microsoft .Net Technology
Microsoft .Net TechnologyMicrosoft .Net Technology
Microsoft .Net Technology
 
.NET Core, ASP.NET Core Course, Session 5
.NET Core, ASP.NET Core Course, Session 5.NET Core, ASP.NET Core Course, Session 5
.NET Core, ASP.NET Core Course, Session 5
 
Embedding Linux For An Automotive Environment
Embedding Linux For An Automotive EnvironmentEmbedding Linux For An Automotive Environment
Embedding Linux For An Automotive Environment
 
Linux container & docker
Linux container & dockerLinux container & docker
Linux container & docker
 
An operational view into docker registry with scalability, access control and...
An operational view into docker registry with scalability, access control and...An operational view into docker registry with scalability, access control and...
An operational view into docker registry with scalability, access control and...
 
Linux internals v4
Linux internals v4Linux internals v4
Linux internals v4
 
4.129 tybsc it
4.129 tybsc it4.129 tybsc it
4.129 tybsc it
 
Dockercon EU 2015 Recap
Dockercon EU 2015 RecapDockercon EU 2015 Recap
Dockercon EU 2015 Recap
 
Diving Through The Layers: Investigating runc, containerd, and the Docker eng...
Diving Through The Layers: Investigating runc, containerd, and the Docker eng...Diving Through The Layers: Investigating runc, containerd, and the Docker eng...
Diving Through The Layers: Investigating runc, containerd, and the Docker eng...
 
Containerization
ContainerizationContainerization
Containerization
 
Native development kit (ndk) introduction
Native development kit (ndk)  introductionNative development kit (ndk)  introduction
Native development kit (ndk) introduction
 

Ähnlich wie Secrets of .NET Assemblies and Memory Management

THE CLR AND THE .NET FRAMEWORK, C#
THE CLR AND THE .NET FRAMEWORK, C#THE CLR AND THE .NET FRAMEWORK, C#
THE CLR AND THE .NET FRAMEWORK, C#MANOJ BURI
 
Interview Question of Aspdotnet
Interview Question of AspdotnetInterview Question of Aspdotnet
Interview Question of AspdotnetMohitKumar1985
 
Net framework session03
Net framework session03Net framework session03
Net framework session03Niit Care
 
assemblies and its types in the computer system
assemblies and its types in the computer systemassemblies and its types in the computer system
assemblies and its types in the computer systemAlameluIyer3
 
.Net platform an understanding
.Net platform an understanding.Net platform an understanding
.Net platform an understandingBinu Bhasuran
 
SynapseIndia dotnet web development architecture module
SynapseIndia dotnet web development architecture moduleSynapseIndia dotnet web development architecture module
SynapseIndia dotnet web development architecture moduleSynapseindiappsdevelopment
 
Vb ch 2-introduction_to_.net
Vb ch 2-introduction_to_.netVb ch 2-introduction_to_.net
Vb ch 2-introduction_to_.netbantamlak dejene
 
Linux Kernel Development
Linux Kernel DevelopmentLinux Kernel Development
Linux Kernel DevelopmentPriyank Kapadia
 
Dotnet interview qa
Dotnet interview qaDotnet interview qa
Dotnet interview qaabcxyzqaz
 
Eclipse Mobile Tools for Java Project
Eclipse Mobile Tools for Java ProjectEclipse Mobile Tools for Java Project
Eclipse Mobile Tools for Java ProjectDavid Marques
 
tybsc it asp.net full unit 1,2,3,4,5,6 notes
tybsc it asp.net full unit 1,2,3,4,5,6 notestybsc it asp.net full unit 1,2,3,4,5,6 notes
tybsc it asp.net full unit 1,2,3,4,5,6 notesWE-IT TUTORIALS
 
Dotnet Basics Presentation
Dotnet Basics PresentationDotnet Basics Presentation
Dotnet Basics PresentationSudhakar Sharma
 
Understanding cil & dynamic assemblies
Understanding cil & dynamic assembliesUnderstanding cil & dynamic assemblies
Understanding cil & dynamic assembliesPaul Fryer
 

Ähnlich wie Secrets of .NET Assemblies and Memory Management (20)

THE CLR AND THE .NET FRAMEWORK, C#
THE CLR AND THE .NET FRAMEWORK, C#THE CLR AND THE .NET FRAMEWORK, C#
THE CLR AND THE .NET FRAMEWORK, C#
 
Assembly
AssemblyAssembly
Assembly
 
Interview Question of Aspdotnet
Interview Question of AspdotnetInterview Question of Aspdotnet
Interview Question of Aspdotnet
 
Dotnet basics
Dotnet basicsDotnet basics
Dotnet basics
 
Net framework session03
Net framework session03Net framework session03
Net framework session03
 
assemblies and its types in the computer system
assemblies and its types in the computer systemassemblies and its types in the computer system
assemblies and its types in the computer system
 
Assemblies in asp
Assemblies in aspAssemblies in asp
Assemblies in asp
 
.Net platform an understanding
.Net platform an understanding.Net platform an understanding
.Net platform an understanding
 
SynapseIndia dotnet web development architecture module
SynapseIndia dotnet web development architecture moduleSynapseIndia dotnet web development architecture module
SynapseIndia dotnet web development architecture module
 
C Sharp Jn
C Sharp JnC Sharp Jn
C Sharp Jn
 
C Sharp Jn
C Sharp JnC Sharp Jn
C Sharp Jn
 
Vb ch 2-introduction_to_.net
Vb ch 2-introduction_to_.netVb ch 2-introduction_to_.net
Vb ch 2-introduction_to_.net
 
Linux Kernel Development
Linux Kernel DevelopmentLinux Kernel Development
Linux Kernel Development
 
Dotnet interview qa
Dotnet interview qaDotnet interview qa
Dotnet interview qa
 
Eclipse Mobile Tools for Java Project
Eclipse Mobile Tools for Java ProjectEclipse Mobile Tools for Java Project
Eclipse Mobile Tools for Java Project
 
tybsc it asp.net full unit 1,2,3,4,5,6 notes
tybsc it asp.net full unit 1,2,3,4,5,6 notestybsc it asp.net full unit 1,2,3,4,5,6 notes
tybsc it asp.net full unit 1,2,3,4,5,6 notes
 
Dotnet Basics Presentation
Dotnet Basics PresentationDotnet Basics Presentation
Dotnet Basics Presentation
 
Understanding cil & dynamic assemblies
Understanding cil & dynamic assembliesUnderstanding cil & dynamic assemblies
Understanding cil & dynamic assemblies
 
introduction to .net
introduction to .netintroduction to .net
introduction to .net
 
Net Interview questions
Net Interview questionsNet Interview questions
Net Interview questions
 

Mehr von Abhishek Sur

Azure servicefabric
Azure servicefabricAzure servicefabric
Azure servicefabricAbhishek Sur
 
Building a bot with an intent
Building a bot with an intentBuilding a bot with an intent
Building a bot with an intentAbhishek Sur
 
C# 7.0 Hacks and Features
C# 7.0 Hacks and FeaturesC# 7.0 Hacks and Features
C# 7.0 Hacks and FeaturesAbhishek Sur
 
Angular JS, A dive to concepts
Angular JS, A dive to conceptsAngular JS, A dive to concepts
Angular JS, A dive to conceptsAbhishek Sur
 
Stream Analytics Service in Azure
Stream Analytics Service in AzureStream Analytics Service in Azure
Stream Analytics Service in AzureAbhishek Sur
 
Designing azure compute and storage infrastructure
Designing azure compute and storage infrastructureDesigning azure compute and storage infrastructure
Designing azure compute and storage infrastructureAbhishek Sur
 
Working with Azure Resource Manager Templates
Working with Azure Resource Manager TemplatesWorking with Azure Resource Manager Templates
Working with Azure Resource Manager TemplatesAbhishek Sur
 
F12 debugging in Ms edge
F12 debugging in Ms edgeF12 debugging in Ms edge
F12 debugging in Ms edgeAbhishek Sur
 
Mobile Services for Windows Azure
Mobile Services for Windows AzureMobile Services for Windows Azure
Mobile Services for Windows AzureAbhishek Sur
 
Service bus to build Bridges
Service bus to build BridgesService bus to build Bridges
Service bus to build BridgesAbhishek Sur
 
Windows azure pack overview
Windows azure pack overviewWindows azure pack overview
Windows azure pack overviewAbhishek Sur
 
AMicrosoft azure hyper v recovery manager overview
AMicrosoft azure hyper v recovery manager overviewAMicrosoft azure hyper v recovery manager overview
AMicrosoft azure hyper v recovery manager overviewAbhishek Sur
 
Di api di server b1 ws
Di api di server b1 wsDi api di server b1 ws
Di api di server b1 wsAbhishek Sur
 
Integrating cortana with wp8 app
Integrating cortana with wp8 appIntegrating cortana with wp8 app
Integrating cortana with wp8 appAbhishek Sur
 
Asp.net performance
Asp.net performanceAsp.net performance
Asp.net performanceAbhishek Sur
 
Introduction to XAML and its features
Introduction to XAML and its featuresIntroduction to XAML and its features
Introduction to XAML and its featuresAbhishek Sur
 
SQL Server2012 Enhancements
SQL Server2012 EnhancementsSQL Server2012 Enhancements
SQL Server2012 EnhancementsAbhishek Sur
 
Dev days Visual Studio 2012 Enhancements
Dev days Visual Studio 2012 EnhancementsDev days Visual Studio 2012 Enhancements
Dev days Visual Studio 2012 EnhancementsAbhishek Sur
 
Hidden Facts of .NET Language Gems
Hidden Facts of .NET Language GemsHidden Facts of .NET Language Gems
Hidden Facts of .NET Language GemsAbhishek Sur
 

Mehr von Abhishek Sur (20)

Azure servicefabric
Azure servicefabricAzure servicefabric
Azure servicefabric
 
Building a bot with an intent
Building a bot with an intentBuilding a bot with an intent
Building a bot with an intent
 
Code review
Code reviewCode review
Code review
 
C# 7.0 Hacks and Features
C# 7.0 Hacks and FeaturesC# 7.0 Hacks and Features
C# 7.0 Hacks and Features
 
Angular JS, A dive to concepts
Angular JS, A dive to conceptsAngular JS, A dive to concepts
Angular JS, A dive to concepts
 
Stream Analytics Service in Azure
Stream Analytics Service in AzureStream Analytics Service in Azure
Stream Analytics Service in Azure
 
Designing azure compute and storage infrastructure
Designing azure compute and storage infrastructureDesigning azure compute and storage infrastructure
Designing azure compute and storage infrastructure
 
Working with Azure Resource Manager Templates
Working with Azure Resource Manager TemplatesWorking with Azure Resource Manager Templates
Working with Azure Resource Manager Templates
 
F12 debugging in Ms edge
F12 debugging in Ms edgeF12 debugging in Ms edge
F12 debugging in Ms edge
 
Mobile Services for Windows Azure
Mobile Services for Windows AzureMobile Services for Windows Azure
Mobile Services for Windows Azure
 
Service bus to build Bridges
Service bus to build BridgesService bus to build Bridges
Service bus to build Bridges
 
Windows azure pack overview
Windows azure pack overviewWindows azure pack overview
Windows azure pack overview
 
AMicrosoft azure hyper v recovery manager overview
AMicrosoft azure hyper v recovery manager overviewAMicrosoft azure hyper v recovery manager overview
AMicrosoft azure hyper v recovery manager overview
 
Di api di server b1 ws
Di api di server b1 wsDi api di server b1 ws
Di api di server b1 ws
 
Integrating cortana with wp8 app
Integrating cortana with wp8 appIntegrating cortana with wp8 app
Integrating cortana with wp8 app
 
Asp.net performance
Asp.net performanceAsp.net performance
Asp.net performance
 
Introduction to XAML and its features
Introduction to XAML and its featuresIntroduction to XAML and its features
Introduction to XAML and its features
 
SQL Server2012 Enhancements
SQL Server2012 EnhancementsSQL Server2012 Enhancements
SQL Server2012 Enhancements
 
Dev days Visual Studio 2012 Enhancements
Dev days Visual Studio 2012 EnhancementsDev days Visual Studio 2012 Enhancements
Dev days Visual Studio 2012 Enhancements
 
Hidden Facts of .NET Language Gems
Hidden Facts of .NET Language GemsHidden Facts of .NET Language Gems
Hidden Facts of .NET Language Gems
 

Kürzlich hochgeladen

Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 

Kürzlich hochgeladen (20)

Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 

Secrets of .NET Assemblies and Memory Management

  • 1. Building Blocks of .NET Framework
  • 2. Agenda 1. Introduction. 2. What is Assembly? 3. Features of Assembly. 4. Benefits of Assembly. 5. Contents of Assembly. 6. Strong Name. 7. Use Of Strong Name. 8. Delay Signing. 9. Categories of Assemblies. a. Single-File Assembly KolkataGeeks 2
  • 3. Agenda (Contd..) 9 b. Multi-File Assembly c. Private Assembly d. Shared Assembly 10. How to install assembly in the GAC. 11. How to remove assembly from the GAC. 12. How to view the contents of assembly? 13. Memory Management. 14. Conditions for a Garbage Collection. 15. Managed Heap. 16. Functions Used By Garbage Collector. KolkataGeeks 3
  • 4. Agenda (Contd..) 17. Phases of Garbage Collection. 18. Finalize Method. 19. Dispose Method. 20. Assembly Manifest. 21. Contents of Manifest. 22. Functions of Manifest. 23. Entry Point 24. Friend Assembly. 25. InternalsVisibleTo 26. GAC & Versioning. KolkataGeeks 4
  • 5. Assembly Assemblies are the building blocks of .NET Framework applications; they form the fundamental unit of deployment, version control, reuse, activation scoping, and security permissions. Assembly is a packet and it contains program and libraries for .NET . It can be used by any program that requires the functionality provided by the assembly. KolkataGeeks 5
  • 6. Versioning - Grouping of modules on the basis of same version information. Deployment - To group code modules and resources that support our model of deployment. Reuse - Modules can be grouped if they can be logically used together for some purpose. For example, if we intend to share our assembly with multiple application, then such assemblies should be grouped together and signed with a strong name. Security - Group modules on the basis of same security permissions. Scoping - Group modules containing types whose visibility should be restricted to the same assembly. KolkataGeeks 6
  • 7. Assembly is basically collection of exe or dll files which are generated upon successful compilation of the .Net application. Assemblies can contain one or more modules. KolkataGeeks 7
  • 8. Features of Assembly Assemblies are implemented as .exe or .dll We can share an assembly by storing it in Global Assembly Cache. Assembly must be assigned strong named, before placing in the Global Assembly Cache. On requirement only, assembly are loaded into memory. Using reflection, we can obtain information about assembly. KolkataGeeks 8
  • 9. Benefits Assemblies are designed to simplify application deployment and to solve versioning problems that can occur with component-based applications. KolkataGeeks 9
  • 10. Solve Versioning Problems Every assembly has a 128-bit version number. This version number is presented as a set of four decimal pieces: Major.Minor.Build.Revision An assembly will use types from the same assembly(name and version) from which it was built and tested. This use of both name and version to identify referenced assemblies avoids the "DLL Hell" problem. KolkataGeeks 10
  • 11. Simplify Application Deployment Assemblies are the natural unit of deployment. The Windows Installer Service 2.0 can install individual assemblies as part of a larger setup program. You can also deploy assemblies in other ways, including by a simple xcopy to the target system. KolkataGeeks 11
  • 12. Contents Of Assemblies Generally, a static assembly consists of 4 elements: 1. Assembly Manifest 2. Type Metadata 3. MSIL 4.Resources KolkataGeeks 12
  • 13. Assembly Manifest Assembly Manifest contains assembly metadata. It contains all the metadata which are required to specify the assembly's version requirements, security identity, scope of the assembly and references to resources and classes. KolkataGeeks 13
  • 14. It contains Assembly name, Version number, Culture, Strong name information , list of all files in the assembly, type reference information , information on referenced assemblies. KolkataGeeks 14
  • 15. Assembly Metadata Metadata is data which contains a detailed description of each type, attribute within the assembly. We can say, it is a collection of data that describes how the elements in the assembly relate to each other. Assembly manifest contains this assembly metadata. KolkataGeeks 15
  • 16. MSIL MSIL is an intermediate language generated by the compiler. All .NET assemblies are represented in MSIL. Microsoft Intermediate Language (MSIL) is a language used as the output of a number of compilers (C#, VB, .NET, and so forth). The ILDasm (Intermediate Language Disassembler) program that ships with the .NET Framework SDK (FrameworkSDKBinildasm.exe) allows the user to see MSIL code in human-readable format. By using this utility, we can open any .NET executable file (EXE or DLL) and see MSIL code. KolkataGeeks 16
  • 17. The ILAsm program (Intermediate Language Assembler) generates an executable file from the MSIL language. We can find this program in the C:WINDOWSMicrosoft.NETFrameworkv4.0.30319. KolkataGeeks 17
  • 18. Creation of MSIL Source Code Compiles Compiler MSIL Converts Into JIT Debugger Native Code KolkataGeeks 18
  • 19. Resource Includes the resource files for the application. KolkataGeeks 19
  • 20. Strong Name Strong names are cryptographic signature, which can be assigned to assemblies. It makes the assembly name unique. KolkataGeeks 20
  • 21. Strong-Name An assemblies identity – its name, version number and public/private key are contained in the strong name. Assemblies name is unique because of its strong name. To sign an assembly with a strong name, we have to use sn.exe utility. Here sn.exe is the strong name generator. KolkataGeeks 21
  • 22. Strong name adds two bits of metadata to the manifest: First one is the unique number which belongs to the authors of the assembly. And the second one is a signed hash of the assembly, which proves that the unique number holder has produced the assembly. This requires a private/public key pair. The public key provides the unique identifying number, and the private key helps in signing. KolkataGeeks 22
  • 23. Use of Strong Name 1. Versioning 2. Authentication Versioning solves known problem called as "DLL hell". Signed assemblies are unique and SN solves problem with namespace collisions .(assembly with the same file name can be distributed by the developers). Assemblies signed with SNs are uniquely identified and are protected. KolkataGeeks 23
  • 24. SN also help developers to uniquely identify versions of their .NET assemblies. Assemblies in the GAC (Global Assembly Cache) must be signed to separate each publisher's namespace and to separate each version. KolkataGeeks 24
  • 25. The second important feature of Strong Names is authentication; a process where we want to ensure ourselves about the code's origin. On adding a strong name, the CLR is allowed to perform verification when the assembly is loaded to determine that it has not been tampered with since it was compiled. KolkataGeeks 25
  • 26. The same situation is when SNs are used. You can remove SNs from assemblies , but this makes no sense because just as in the case of emails, assemblies without SNs can't be trusted when environment is set up to require those digital signatures or SNs. KolkataGeeks 26
  • 27. While developing an application that has a strong name, all libraries it uses must also have a strong name. We cannot refer to an assembly without a strong name from an assembly with a strong name. KolkataGeeks 27
  • 28. Delay Signing We might want to restrict access to the key pairs used for signing assemblies. The reasons is, if a key-pair is leaked, assembly is tamperable. Again if key pairs are not given to the developers, they cannot compile and test assemblies with their correct identity. This critical problem can be resolved using ‘Delay Signing’. KolkataGeeks 28
  • 29. A delay signed assembly contains the public key and not the private key. The developer instructs the CLR, to bypass the validation for the delay-sign assemblies. At the time of final deployment, the private key holder re-signs the assembly with the real key pair. KolkataGeeks 29
  • 30. Delay Sign If we specify to delay sign the assembly, the compiler in that case, does not sign the assembly. We will also discover that the runtime considers the assembly to be invalid and will not load it or allow us to debug and run it. KolkataGeeks 30
  • 31. Steps for Delay Signing 1. Create a key pair Sn –k mykey.snk 2. Separate the public and the private key. Extract the public key and keep it in its own file. Sn –k mykey.snk myPublicKey.snk 3. Place the details in the AssemblyInfo.cs <assembly:AssemblyKeyFileAttribute("myPublicKey.snk")> <assembly:AssemblyDelaySignAttribute(true)> 4. To skip the signature verification for the assembly sn -Vr mydll.dll KolkataGeeks 31
  • 32. 5. Just before shipping, the signing authority of the company, signs with the actual strong name using –R option of the Strong Name tool. sn -R mydll.dll Testkey.snk KolkataGeeks 32
  • 35. Single-File Assembly We can group all elements of an assembly in a single physical file. KolkataGeeks 35
  • 36. Single File Assembly SingleFileAssembly.dll Assembly Manifest Type Metadata MSIL Resources KolkataGeeks 36
  • 37. Modules Modules are the containers, which holds the contents of an assembly. A module corresponds to a file, containing the contents of an assembly. This extra containership is helpful in case where assembly contains multiple files. KolkataGeeks 37
  • 38. MultiFile Assembly We can create a multifile assembly from several code modules and resource files. The elements of an assembly can be contained in several files. Modules of compiled code(.netmodule) and resources(.bmp), or other files required by the application, can be put together to make a multifile assembly. KolkataGeeks 38
  • 39. In a multi-file assembly, the main module, always contains the manifest; additional modules can contain IL and /or resources. The manifest describes the relative location of all the other modules that make up the assembly. KolkataGeeks 39
  • 40. Multi-File Assembly MultiFile.dll Util.netmodule • Type Metadata • Assembly Manifest • MSIL Code • Type Metadata • MSIL Code Graphic.bmp • Resources KolkataGeeks 40
  • 41. Here all the three files belong to an assembly. Util.netmodule is compiled as a separate module. And it contains no manifest. When the assembly was created, assembly manifest was added to the multifile.dll. This manifest indicates its relationship with util.netmodule and graphic.bmp. KolkataGeeks 41
  • 42. How to create mulifile assembly KolkataGeeks 42
  • 43. The module parameter with the /t compiler option indicates that the file should be compiled as a module. With the following command, a module named Class1.netmodule is created, which can be added to an assembly. KolkataGeeks 43
  • 44. Now we have to compile modules with respect to other modules. So let’s write the code first: KolkataGeeks 44
  • 46. /t:module is used to create a module, which can be added to an assembly in future. /addmodule: is used to reference a namespace created in Class1.netmodule. The compiler produces a module called MainClient.netmodule that contains a reference to another module, Class1.netmodule. KolkataGeeks 46
  • 47. Creating a multifile assembly Class1.netmodule and MainClient.netmodule are included in the assembly. The /main: option specifies the assembly’s entry point. The /out: option specifies the name of the output file, which will contain the assembly metadata. /target: option specifies the assembly file type. KolkataGeeks 47
  • 50. Private Assemblies Assemblies which are used for each application separately. On creation of an assembly, it is private by default. This type of assembly cannot be used by any other application, until and unless this assembly is copied separately in the respective application’s folder. KolkataGeeks 50
  • 51. Let us create a ClassLibrary. Then we are going to build it. After building, .dll is created. KolkataGeeks 51
  • 52. Now we can find that really, .dll file has been created in the bin folder. Now we want to use this .dll in our new console application. KolkataGeeks 52
  • 53. Now I have created my application. Added the .dll by References->Browse. And as we can see, I have also used the ClassLibrary1 on the top. KolkataGeeks 53
  • 54. This is the output. And it shows that the use of private assembly. KolkataGeeks 54
  • 55. Separate copy of ClassLibrary1.dll has been copied here. So this is Private Assembly. KolkataGeeks 55
  • 56. Shared Assembly Shared assembly can be used in situations where it is not necessary to install a version of an assembly for each application that uses it. KolkataGeeks 56
  • 57. Shared Assembly To make a shared assembly, we require it to store in Global Assembly Cache GAC. GAC is reserved for storing assemblies and for sharing them in between different applications. Here every assembly must have an unique name. So we need to assign strong name to assemblies before storing it in the GAC. KolkataGeeks 57
  • 58. Pictorial representaion of Shared Assembly Application1 GAC Application4 Application2 (shared assembly) Application3 KolkataGeeks 58
  • 59. Each assembly is assigned a strong name. Assigning Strong Name KolkataGeeks 59
  • 60. Adding .dll in the GAC How to install .dll into GAC KolkataGeeks 60
  • 61. Location of Shared Assembly Here our shared assembly is located. KolkataGeeks 61
  • 63. Here no separate copy of assembly is pasted in the ConsoleApplication3bindebug folder. Instead here the shared assembly from the GAC has been used. Common Copy of Shared Assembly has been used here. KolkataGeeks 63
  • 64. Remove an assembly from GAC We have to use Global Assembly Cache tool(gacutil.exe) to remove an assembly from the GAC. Syntax: At the Command prompt: Gacutil /u assemblyname Here /u means uninstall. And assemblyname is the name of the assembly, which we want to remove from the GAC. KolkataGeeks 64
  • 65. View the contents of assembly Let’s write some code and compile it. Assembly will be created. Type a command ildasm from the command prompt. An application will be open, name Intermediate Language Disassembler. This application opens our assembly and shows all classes, methods , data fields, global and local application data. KolkataGeeks 65
  • 66. To view the contents of a manifest for a particular assembly, we can use the ILDassembler(ILDasm.exe), which is part of the .NET Framework SDK. KolkataGeeks 66
  • 69. Ildasm window opens. File->Open->Browse for our .dll file. KolkataGeeks 69