---
title: "GAC in .NET"  
description: "Each computer where the common language runtime is installed has a machine-wide code cache called the global assembly cache. The global assembly cache"  
author: "AVADHESH PATEL"  
published: 2012-07-09  
updated: 2019-09-07  
canonical: https://www.mindstick.com/articles/956/gac-in-dot-net  
category: ".net"  
tags: [".net"]  
reading_time: 2 minutes  

---

# GAC in .NET

Each computer where the [common language runtime](https://www.mindstick.com/articles/16/common-language-runtime) is installed has a machine-wide code cache called the [global assembly](https://www.mindstick.com/forum/158850/what-is-the-purpose-of-the-global-assembly-cache-gac-in-dot-net-core) cache. The global assembly cache stores .net assemblies specifically designated to be shared by several [applications](https://www.mindstick.com/articles/12847/how-to-choose-the-right-ethernet-cable-for-industrial-applications) on the computer.\

You should share assemblies by installing them into the global assembly cache only when you need to. As a general guideline, keep assembly dependencies private, and locate assemblies in the [application](https://www.mindstick.com/articles/12824/calculator-application-in-android) directory unless sharing an assembly is explicitly required. In addition, it is not necessary to install assemblies into the global assembly cache to make them accessible to COM interop or unmanaged code.

You should share assemblies by installing them into the global assembly cache only when you need to. As a general guideline, keep assembly dependencies private, and locate assemblies in the application directory unless sharing an assembly is explicitly required. In addition, it is not necessary to install assemblies into the global assembly cache to make them accessible to COM interop or unmanaged code.

![GAC in .NET](https://www.mindstick.com/mindstickarticle/d08e6f26-37fe-4901-b729-e92f81072694/images/688c8cd5-e45c-48c7-8613-e863babb93cf.png)

##### Use of GAC

Making two folder namely “service” and “consumer”

![GAC in .NET](https://www.mindstick.com/mindstickarticle/d08e6f26-37fe-4901-b729-e92f81072694/images/56c0e4e0-80ce-4142-92a6-6bc497f1b25e.png)

“show.cs” file save in “service” folder and “check.cs” file save in “consumer” folder

![GAC in .NET](https://www.mindstick.com/mindstickarticle/d08e6f26-37fe-4901-b729-e92f81072694/images/65bf1243-dd85-4e12-8458-743d7bff3ab2.png)

![GAC in .NET](https://www.mindstick.com/mindstickarticle/d08e6f26-37fe-4901-b729-e92f81072694/images/52d8aab3-1ac6-4f75-a446-4f9de18e61fe.png)

D:\ service>csc /t:library show.cs

ð Show.dll is created

![GAC in .NET](https://www.mindstick.com/mindstickarticle/d08e6f26-37fe-4901-b729-e92f81072694/images/dc9fa467-14f3-47b0-aa2d-8cbd716fa245.png)

D:\consumer>csc /r:d:service\show.dll check.cs

D:\consumer>check.exe is created

![GAC in .NET](https://www.mindstick.com/mindstickarticle/d08e6f26-37fe-4901-b729-e92f81072694/images/c8de9c34-e5e5-48e1-9689-f68fcda19e4e.png)

D:\consumer>check

![GAC in .NET](https://www.mindstick.com/mindstickarticle/d08e6f26-37fe-4901-b729-e92f81072694/images/a2aedc93-4385-4aed-b29f-3c069132341d.png)

Authentication problem occurs

![GAC in .NET](https://www.mindstick.com/mindstickarticle/d08e6f26-37fe-4901-b729-e92f81072694/images/c778ea70-a382-43e8-ad14-17e3f47a4efe.png)

In the above snapshoot check.exe file not execute due to [authentication](https://www.mindstick.com/blog/177/authentication-and-authorization-in-asp-dot-net) problem. For solving this, make [strong name](https://www.mindstick.com/blog/495/strong-name-in-dot-net) and attached with **cs** file and then make dll. Mapped dll in assembly folder (***C:\Windows\Assembly***), with the help of gacutil command. This process called shared assembly.

---

Original Source: https://www.mindstick.com/articles/956/gac-in-dot-net

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
