Exe actually run in owe memiries space. Start (a static method) calls external applications. An EXE runs instructions. We start this EXE as a process.


He can not invoke by him salf.  He need the hoster or consumer howwill minvoke it. DLL will run inside some other memory space. DLL not run his own mwmory space . we develop a small DLL and a test container for that. This DLL will export three functions, each from one class in a namespace.

namespace MyDLL
  public class AddClass
 public string Mrthod()
Class obj = new Class();
return "this is DLL";

Add the following three classes to this project. Name them something like AddClass.cs, MultiClass.cs, and FactorialClass.cs.

Listing 1. AddClass.cs

using System;
namespace MathFunctions
  public class AddClass
    public static int Add(int a, ant b)
      return (a+b);

Listing 2. MultiClass.cs

using System;
 namespace MathFunctions
  public class MultiClass
    public static int Multiply(int a, int b)
      return (a*b);

Listing 3. FactorialClass.cs

namespace MathFunctions
  public class FactorialClass
    public static int Factorial(int i)
      return((i <= 1) ? 1 : (i * Factorial(i-1)));

Our idea is to export AddClass::Add, MultiClass:: Multiply, and FactorialClass::Factorial from the namespace MathFunctions. That’s it; we’re finished coding.


Assembly is a precompile .net code, which can be run by the CLR. It is the single unit deployment.  All the .NET assemblies contain the definition of types, versioning information for the type, meta-data, and manifest. The designers of .NET have worked a lot on the component (assembly) resolution.

There are two kind of assemblies in .NET.

  1. private
  2. shared

 1. Private

Assembly available only to clients in the same  directory. Private assemblies are simple and copied with each calling assemblies in the calling assemblies folder. All the assembly contain the definition of type version information of the metadeta and the manifast . An assembly contian of one or more file .

A private assembly is not required to be signed, and publickeyToken is not required in the assemblyIdentity element of the assembly manifest.

Assemblies which are used by single application are called “Private Assemblies”. In this case, the bin\Debug\*.dll gets copied in the folder, in which the client application is present.

Let me cite an example here.

Start->All Programs-> New->Project->ClassLibrary


I have named it as Happy. The code follows here:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Happy
    public class Class1

        public Class1()
          Console.WriteLine("wish you happy new year");


Now it is the time to compile. So click at Build->Build Solution.

With this, Happy.dll is created at C:\Happy\Happy\bin\Debug


We have to use our .dll file in new ConsoleApplication. So create a new ConsoleApplication. It is named as UseOfDll.


Right Click on Solution Explorer->Add Reference->

With this Add Reference Dialog box open. From here, we have to browse our respective .dll file and press OK button.


Now, Solution Explorer shows, that .dll file is being added under References. We have used the Happy namespace.


Let me run the program and get the output.

Shared Assembly

Shared assembly deploes in a GAC which called shared assembly . shared assembly are generally installed in GAC. Shared assembly use by several application.

A shared assembly is an assembly that resides in a centralized location known as the GAC (Global Assembly Cache) and that provides resources to multiple applications. If an assembly is shared then multiple copies will not be created even when used by multiple applications.

Creating A shared assembly

Step 1: Generate a key file. Open a VS command prompt. Go into your folder and generate a key file as:

<drive>:\<folder> sn -k key.snk

Step 2: create a project and associate a key file to it before compilation so that the generated assembly will be strong named.

Open a new project of type class library and name it sAssembly; under class1 write the following:

Public string sayhello()
Return "hello from shared assembly";

To associate a key file we generated with the project, open the project properties and select the “signing” tab on the LHS which displays a CheckBox as “sign the assembly” select it that displays ComboBox below it from it select browse and select key.snk from its physical location then compile the project using build which will generate assembly Assembly.dll that is strong named.

Step 3: copying the assembly into GAC

.Net provides a command line utility to be used as shown in the following:

Gacutil -I | -u <assembly name> I:install u:uninstall

Open a VS command prompt; go to the location where the Assembly.dll is present and write the following:

<drive>:\<folder>\sAssembly\ sAssembly\\bin\Debug>gacutil -I Assembly.dll

Step 4: Testing

Open a new project add a reference to Assembly.dll and write the following code for the button click event.

sAssembly.Classs1 obj=new sAssembly.Class1();


Run the project and verify under the bin/debug folder of the current project where we will not find a copy of the Assembly.dll as it is a shared assembly.

Globle Assembly cache(GAC)

GAC is ues when Assembly  has to be shared among serveral appilication which are installed in the same computer. If the Assembly has same special security requirements like only administrators can remove the assembly.

Each computer where the common language runtime is installed has a machine-wide code cache called the global assembly cache. The global assembly cache stores assemblies specifically designated to be shared by several applications on the computer.

There are two ways to deploy an assembly into the global assembly cache:

  1. Use an installer designed to work with the global assembly cache. This is the preferred option for installing assemblies into the global assembly cache.
  2. Use a developer tool called the Global Assembly Cache tool (Gacutil.exe), provided by the Windows Software Development Kit (SDK).


The assembly manifest contains this assembly metadata. An assembly manifest contains all the metadata needed to specify the assembly’s version requirements and security identity, and all metadata needed to define the scope of the assembly and resolve references to resources and classes.

Metadata is stored in manifest. manifest cantain all the metadata needed to  thinks.

  1. Enumerates the files that make up the assembly.
  2. Governs how references to the assembly’s types and resources map to the files that contain their declarations and implementations.
  3. Enumerates other assemblies on which the assembly depends.
  4. Provides a level of indirection between consumers of the assembly and the assembly’s implementation details.
  5. Renders the assembly self-describing.


Metadata is data that describes the state of the assembly and a detailed description of each type, attribute within the assembly. Metadata is stored in one section of a .NET Framework portable executable (PE) file, while Microsoft intermediate language (MSIL) is stored in another section of the PE file. The metadata portion of the file contains a series of table and heap data structures.

Metadata stores

  1. Description of the assembly.
  2. the type that are exported.
  3. Security permission needed to run.


A satellite assembly contain resource specific to given language using satellite assemblies. If you place resource for different language in different assemblies and the correct assembly is loaded into memory only if the user selects to view the application in the  language.

A satellite assembly is a .NET Framework assembly containing resources specific to a given language. Using satellite assemblies, you can place resources for different languages in different assemblies, and the correct assembly is loaded into memory only if the user selects to view the application in that language.

Using assembly liker to compile resource files into satellite assemblies.