---
title: "What Is Shared Assembly ?"  
description: "What Is Shared Assembly ?"  
author: "Anonymous User"  
published: 2019-12-12  
updated: 2019-12-12  
canonical: https://www.mindstick.com/forum/155587/what-is-shared-assembly  
category: ".net"  
tags: [".net", ".net assembly"]  
reading_time: 3 minutes  

---

# What Is Shared Assembly ?

[please explain](https://www.mindstick.com/forum/344/hi-rohith-i-am-new-for-mvc-please-explain-how-to-set-implicitly-isauthenticated-true) What Is [Shared](https://www.mindstick.com/interview/33677/describe-shared-hosting) Assembly ?

## Replies

### Reply by Nishi Tiwari

**Public or shared assembly** used by multiple application, if more than one application use assembly than that assembly must be add or copy to single location known as **[Global Assembly Cache (GAC)](https://www.mindstick.com/forum/155582/what-is-global-assembly-cache-gac-in-dot-net-framework)**. For calling assemblies within same application the same copy of shared assembly is used from original location. Shared assembly contains four part name including face name, version, public key token and cultural information. Public key token and version information makes impossible for two different assembly with same name or same assembly with different version to mix with each other.

## Another definition for shared assembly

A shared assembly can also be defined as an assembly that placed in a common location known as the GAC (Global Assembly Cache) and that provides resources to the application. If an assembly is shared then it doesn’t mean that multiple copies will be created even when it is used by multiple applications. The GAC folder is contained under the Windows folder.

<drive>:\windows\assembly <GAC folder>

All base class libraries lie under GAC.

A strong named assembly is given into the GAC.

GAC is identified by public key token.

Generating a public key token:

we use command prompt by using strong named util tool which is command line tool.

Sn -k <file name>

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

This above statement generates a key value and write it into "key.snk" file.

sn or snk used above is the extension of key file.

How to Create A shared assembly

**Step 1: First Generate a key file.**

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

**Step 2: now create a new project and attached key file to it before compilation so that a strong named assembly will be generated.**

create a new project of type class and name it sAssembly;

Public string SayHello()

{

Return "hello to shared assembly";

}

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

**Step 3: the third step is to copy the assembly into GAC.**

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

now, open a VS command prompt;and went to that location where Assembly.dll file is present and the following code

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

## Step 4: Testing

Add reference of a Assembly.dll file to open new project and write the code for the button click event.

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

Messagebox.Show(obj.SayHello());

At last run the project and verify under the current project of bin/debug folder, as **[Assembly.dll](https://www.mindstick.com/forum/155581/what-is-assembly-in-dot-net-framework)** is shared assembly we cannot find it into the folder.

![What Is Shared Assembly ?](https://www.mindstick.com/mindstickforums/665d0859-b12f-4544-9653-043d2ae5f32e/images/6805af7f-d18f-4ca2-8a90-11e8e256af63.jpeg)


---

Original Source: https://www.mindstick.com/forum/155587/what-is-shared-assembly

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
