120 likes | 261 Views
Global Assembly Cache (GAC). What is GAC. Repository containing all the assemblies of CLR Machine wide Assemblies shared by several applications Where CLR is installed C:WindowsMicrosoft.NETassemblyGAC_MSIL. Why we have to use GAC. Adding again and again assembly in different project
E N D
What is GAC • Repository containing all the assemblies of CLR • Machine wide • Assemblies shared by several applications • Where CLR is installed • C:\Windows\Microsoft.NET\assembly\GAC_MSIL
Why we have to use GAC • Adding again and again assembly in different project • Shared location • File security • Side by side versioning (under consideration) • Additional search location
How to install an assembly in GAC • Install by using the gacutil.exe tool • Recommended for developers • Install by using GUI interface of Windows installer
How to make an assembly(.dll) • Create a library project in Visual studio • Add some functions • To sign an assembly with a strong name • public/private key pair • Use this command to make a key • sn -k <keyname>.snk • It creates a key pair file “keyname.sn”
How to make an assembly(.dll) cont… • Put the key file in library project
How to install an assembly(.dll) Method -1 • Open Visual Studio Command Prompt • Use this command to register assembly • gacutil.exe –i myassembly.dll • It creates the folder with assembly • C:\Windows\Microsoft.NET\assembly\GAC_MSIL
How to install an assembly(.dll) Method -2 • Create a new setup project in same solution • Drag the assembly to the GAC folder • Build the setup project and install it • It creates the folder with assembly • C:\Windows\Microsoft.NET\assembly\GAC_MSIL
How to register an assembly(.dll) cont… • Open registry and go to this path • Create a registry key with assembly location • For 32 bit • [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\VersionMinimum\AssemblyFoldersEx\MyAssemblies]@="AssemblyLocation“ • [HKEY_CURRENT_USER\SOFTWARE\Microsoft\.NETFramework\VersionMinimum\AssemblyFoldersEx\MyAssemblies]@="AssemblyLocation"
How to register an assembly(.dll) cont… • For 64 bit operating system • [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\VersionMinimum\AssemblyFoldersEx\MyAssemblies]@="AssemblyLocation" • [HKEY_CURRENT_USER\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\VersionMinimum\AssemblyFoldersEx\MyAssemblies]@="AssemblyLocation“
Use assembly in Visual Studio • Assembly is created under .NET column • Just right “using assembly name;” and enjoy