You can locate GAC folder inside Windows directory. GAC folder contains only strongly named assemblies. All applications that are running on your machine can access GAC folder and use its assemblies. Benefits of storing strongly named assemblies inside GAC are:
- There is no need to distribute that particular assembly with every new version of application
- Assemblies stored in GAC folder are strongly named so you need not to worry about having two or more version of same assembly distributed.
How can i locate GAC folder?
There are actually two locations:
- Location for assemblies created with .Net Framework 2.0 to .Net Framework 3.5
- Location for assemblies created with .Net Framework 4.0 and newer
Usually you cal locate it by typing C:\Windows\assembly for older strongly named assemblies or C:\Windows\Microsoft.NET\assembly for newer strongly named assemblies.
If your machine is not installed on C drive or your windows folder is not named Windows simply type in File explorer : %WINDIR%\Assembly or %WINDIR%\Microsoft.NET\assembly and you there you can find GAC folder.
How to install Strongly named assembly inside Global Assembly Cache?
Add new Class library project to Solution and name it AssemblyToInstall and strong name it.
Drag and drop approach:
Just simple locate bin\Debug folder inside AssemblyToInstall project, locate AssemblyToInstall.dll file and drop it to appropriate location (C:\Windows\Microsoft.NET\assembly). Note that you can do this only if your user has elevated privileges.
If you are using Visual Studio 2013 or 2015 version, you can search for Developer Command Prompt and run it as Administrator.
New console will open.
Navigate to project. Mine is located on D drive under charp folder
Next you will need to run gacutil toll with -i parameter (basically -i switch is telling gacutil that we want to install assembly) followed by Assembly dll we want to install.
run command: gacutil.exe -i AssemblyToInstall.dll
You should receive message: “Assembly successfully added to the cache”
If you receive message: “Failure adding assembly to the cache: Attempt to install an assembly without a strong name”. That means that you have not signed assembly.
Now navigate to %WINDIR%\Microsoft.NET\assembly\GAC_MSIL\AssemblyToInstall and there you can see your assembly and can use that path to provide reference to that assembly to all applications located on this machine.
Tomorrow we will continue with topic on how to implement side-by-side hosting.