Working with assemblies in C# .net
  • Share this blog:


  1. A DLL file is called as an Assembly.


  1. Assembly contains reusable code in the format of byte code.
  2. A collection of classes is called namespace
  3. Collection on namespaces is an assembly
  4. Collection of Assemblies is FCL (Framework Class Library)
  5. Assembly supports language interoperability

That is the assembly developed in C can be used in Vb .net and also and vice versa.

  1. In some cases, C assembly may not work in VB.Net
  2. To add an assembly


Interested in mastering .NET? Learn more about ".NET Training" in this blog post.

Go to project menu  arrrow Add reference arrrow  Browse arrrow choose a DLL file

  1. To import the classes of namespace “using” keyword is required.
  2. DLL arrrow System. DATA arrrow System. DATA. OLEDB


  1. Assemblies are divided into two types
  2. Private
  3. Shared


  1. In private assemblies, all the referred DLLS will be copied automatically into LOCAL projects debug folder.
  2. In shared assemblies, the referred DLLS will not be copied into LOCAL project debug folder.
  3. Private assemblies occupies more memory when these are referred from many projects.
  4. When many projects to be developed for the same client, then shared assemblies are recommended. if only one project is required for a client, then private assemblies are best.   

Example on Private Assembly:-

  Note: - To develop assemblies .net introduced class library project template

  • Open a class library project with the project
  • Private test (output will be a private test. dll)

  Note:- DLL files are not executable, only it contains reusable code.  

OBS: -

For every project, by default, a namespace will be created with the name of the project.  

Namespace private e test


Public class test


Public string M1 ()


Return “form M1”;






Namespace sub private Test


Public class test 2


Public String Print ()


Return “from print”;



Public string PRINT ()


Return “from PRINT”;





}//sub private test


//private test   Build the project  (build menu arrrowbuild solution)  


  Private test. DLL is created under D:/C194 /private test / bin / debug folder with the following Structure  


Similar to System. Io

  • Calling private Test. DLL from a C Windows Application Project
  • Open WFAP with project name c Test (C test or any name)
  • Go to project menu arrrowAdd referencearrrow Browse arrrow private Test .dll
  • Place a button

Using private test;                                             

both should be returned if one write, Using private test. Sub private Test; 

                   then only that namespace classes all user  

// code for button


Test t = new test ();

Message Box . show (t. M1());

Test 2 S = new Test 2 ();

Message Box . show (S. Print ());

Message Box . show (S. Print ());


Execute the Project (f5):-

  When the project is executed then private Test. DLL is copied into C :/c 194/Ctest/Bin/debug folder, hence private Test. DLL is a private assembly.

  • Calling Private Test.Dll from
  • Windows Application Project

  arrrowopen windows Application Project with name V Test.  

Project Menu

arrrowAdd reference

arrrow Browse

 arrrow Private Test.

DLL Place a button Imports Private Test  

Imports Private Test. Sub Private Test //code for b1_click Dim t As New Test Message Box (t1. M1()) Dim S As New Test2 Message Box (S. print ())//can not be called.

Note: - Test 2 is having two methods with name print and PRINT where the only case is different. This type of method is not accessible from because is not case sensitive.  

    Working with Shared Assemblies:-


  1. ALL DLL file which is registered with GAC is called a shared Assembly.

GAC – Global Assembly cache

  1. C:/windows/Assembly folder is called as GAC.
  2. Assembly folder a secured folder where copy and paste is not allowed.
  3. A DLL, which contains a strong name can be registered with GAC.
  4. A strong name is also called a public key token, which provides a unique identifier, to as an assembly.
  5. Syntax to create a Strong name

Sn – K abc.snk   Small case  

  1. A DLL with strong name can be registered with GAC with the help of GacUtil tool.

  Gacutil  -I  dll file

  • Small
  • Install

  -u arrrow uninstall

Example on shared Assembly:-

  • Open class library project with project name asc 123

  Namespace ABC 123 { Public Class Test { Public String Get Test () { Return “from get text”; }//get text }//text }//ABC 123    

Steps to create a Strong name in C# .net

  • Open .net command prompt

(Start arrrowPrograms arrrowMicrosoft Visual Studio 2008 arrrowVisual Studio Tools arrrow visual Studio 2008 command prompt ) D: enter key

  • Cd c 1194
  • C 194 > cd abs 123

  Abc 123 >cd bin Abc 123/bin > cd debug  


  Abc.snk file is created with a strong name linking abc.snk in the current project Project menu

arrrowAbc 123 Properties


arrrowcheck the “Sign the assembly” checkbox

arrrow Select “browse” from the combo box

arrrow choose ABC.snk file

Providing Meta Information  (optional):

Project menu

 arrrowABC 123 Properties

 arrrow Application

arrrow Click on the Assembly Information button and type some information.  

Build the project  (buildarrrow build Solution)  


ABC 123. DLL is created under D:/c194 /ABC 123 / Bin /Debug folder Open .net command prompt and type as follows Gacutil – I abc 123.dll  


ABC 123. DLL is registered with GAC (C :/windows/Assembly)  hence it is called as shared Assembly.

Open windows Forms Application Project  with Project name WINTEST Project menu

 arrrowAdd reference


arrrow Abc 123.dll Place a Button Using ABC 123 Namespace WINTEST

Code for Button1_click


Test t  = new Test ();

Message Box. Show  (t. Get Text ());


Execute the Project  (f5)  


  ABC123.DLL is not copied into D :/ c194/WINTEST/bin /Debug folder, hence Abc 123.DLL is a Shared Assembly  


  All predefined assemblies are shared assemblies

You liked the article?

Like : 0

Vote for difficulty

Current difficulty (Avg): Medium

Recommended Courses


About Author
Author Bio

TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills in the market.

Stay Updated

Get stories of change makers and innovators from the startup ecosystem in your inbox