---
title: "Introduction to .Net Assembly"  
description: "It is a smallest unit of deployment of .net application or .net project.  It can be in the form of .dll(dynamic link library) and executable( .exe.) ."  
author: "Manish Kumar"  
published: 2017-01-19  
updated: 2018-03-17  
canonical: https://www.mindstick.com/blog/11272/introduction-to-dot-net-assembly  
category: ".net"  
tags: [".net", "assembly"]  
reading_time: 3 minutes  

---

# Introduction to .Net Assembly

It is a smallest unit of [deployment](https://www.mindstick.com/articles/325966/process-of-application-development-and-deployment) of .net [application](https://www.mindstick.com/articles/12824/calculator-application-in-android) or .net project. It can be in the form of .dll(dynamic link library) and executable( .exe.) .It is typically a compiled output of our code. An assembly gives fundamental unit of physical code. **It is a [collection](https://www.mindstick.com/articles/1718/collections-in-java) of all types** and resources .Every time we make a Windows Application, Windows Service, [Class Library](https://www.mindstick.com/forum/158577/what-is-the-significance-of-the-base-class-library-bcl-in-the-dot-net-framework) with Visual Basic .NET, that means we are creating an assembly.

## There are two types of assemblies

- Private Assembly
- Shared Assembly
- Private Assembly

Private assembly is available for any single application. We cannot use private assembly for multiple application.

Now we take an example of creating private assembly

**Step 1-**

Select new project and select class library and name it ClassLibrary1

![Introduction to .Net Assembly](https://www.mindstick.com/blogs/1c353743-655b-4c65-a1df-c24179e52567/images/7e7f3f1b-8881-45d7-b1fc-ffba20f05624.png)\

**Now add following code for creating library**

```
using System;                  using
System.Collections.Generic;using System.Linq;using System.Text;using
System.Threading.Tasks; namespace ClassLibrary1{    public class Class1    {        public void str(int x)        {            Console.WriteLine("interger");        }         public void str(string y)        {            Console.WriteLine("string");        }         public static void Main()        {            Class1 obj = new Class1();            obj.str("Manish");                      Console.ReadKey();        } 
    }} 
```

\

**Your library is created in bin folder with .dll extension.**

Now add another project of console application and now add reference and browse. When we select your library it will be added in your reference

![Introduction to .Net Assembly](https://www.mindstick.com/blogs/1c353743-655b-4c65-a1df-c24179e52567/images/fde3db92-5f63-46f6-b826-6f784b3801dc.png)\

## For adding assembly do following code

```
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using ClassLibrary1;namespace ConsoleApplication4{    class Program    {        public static void Main()        {            Class1 obj = new Class1();            obj.str("manish");                    Console.ReadKey();        }     }}
```

\

In this first make the object of class of library and by object we can access

\

all method of library. And for adding library we use using Library Name

This is the example of private assembly we [cannot access](https://www.mindstick.com/forum/33726/inside-onclicklistener-i-cannot-access-a-lot-of-things-how-to-approach) it in another

application.

## Shared Assembly

Shared assembly is for many application we can use it in more than one

application. It is kept in [global assembly](https://www.mindstick.com/forum/158570/what-is-the-global-assembly-cache-gac-and-how-is-it-used-in-dot-net) cache. It is also known as strong

named assembly.

**For creating strong named assembly**

1-create a .dll file. (Using previous ClassLibrary1.dll)

\
2 Create a unique assembly name using SN utility (Shared Name utility).

\
For creating this syntax for it is: sn -k filename.snk

\
sn stands for [strong name](https://www.mindstick.com/articles/440/what-is-strong-name-in-assembly),

-k stands for key and

key is stored in filename.snk .

**[Difference between Private](https://www.mindstick.com/interview/23202/what-is-difference-between-private-assembly-and-shared-assembly) assembly and Shared Assembly**

Private assembly cannot reference outside the scope of the folder where they are kept

Shared assembly is one that can be referenced by more than one application. \

## Difference between Private assembly and Shared Assembly

Private assembly cannot reference outside the scope of the folder where

they are kept

Shared assembly is one that can be referenced by more than one

application.

**You can also visit these useful related links**

[Where the assembly is stored in asp.net\](https://www.mindstick.com/interview/1021/where-the-assembly-is-stored-in-asp-dot-net)

[How does assembly versioning in .net prevent DLL Hell](https://www.mindstick.com/interview/494/how-does-assembly-versioning-in-dot-net-prevent-dll-hell)

---

Original Source: https://www.mindstick.com/blog/11272/introduction-to-dot-net-assembly

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
