I thought I’d cover the intricacies of deploying .NET Dll’s in production and development environments today. One of a developers’ first tasks after creating an assembly is deciding the location to house their newly creating endeavour. The three main ways are
- Global Application Cache (GAC)
- Private Assemblies
Global Application Cache
Storing your assembly in the “Global Application Cache” (GAC) , allows your assemblies functionality to be utilized across several different applications. Once the assembly is in the GAC, the CLR (by default) will search this universal location for the applicable assembly.It is the first location the CLR will search for assemblies.
The location of the GAC is C:\Windows\Assemblies\GAC. There are a number of ways to deploy your assembly to the GAC. The main way is by calling the command line utility GACUtil.exe
- Shared between applications
- Eliminates dependency on relative/absolute path referencing correctness
- Small load performance boost (Load time strong naming verification not required as it’s a pre-requisite for GAC deployment)
- Requires at least power user access control to deploy to GAC
- Requires assembly strong naming
The developer’s application directory is also know as the ApplicationBase, and is the private location where the CLR searches for assemblies.
- XCopy deployment (copy application assemblies, config files to a single location for deployment)
- Flexible options in strong/weak naming and user installation access control
- Cannot share private assemblies between applications
This property allows the developer to specify a location to find an assembly (e.g. relative paths or web download). If the assembly is downloaded from the network then the assembly is copied and loaded from a location known as the download cache. Note that this location is not the same location as the GAC and hence does not provide the same capabilities such as assembly sharing.
- Obtain the assemblies over the network
- Not restricted to ApplicationBase structure
- Important to get correct directory in config file.