Going GAC

There are basically two ways to link an assembly to a application. Normally you do not need to share the assemblies so copying the assembly DLL along with the application works just fine. These are so called private assemblies. The CLR will probe for the the file starting from the application folder. No version checking is performed, so updating can be done simply by XCOPY.

In some cases you need to enable applications to share the same assembly. In cases like this the GAC (Global Assembly Cache) comes in handy. The GAC enables you to register assemblies for applications to load. The only requirement is that the assembly must have a strong name for identification. One of the advantages of using the GAC is that you can have multiple versions of the same assembly available. The assemblies in the GAC are called public assmeblies and registering them is a trivial task. During development you might just want to drag-n-drop the DLL file to the C:\Windows\Assemblies folder using the Windows Explorer or use the gacutil.exe through the command prompt. Setting up an installer to register you assemblies on the user systems is also a simple task and will be described next.

What you need is a simple setup project.  To get the assembly registered just add a “Global Assembly Cache Folder” to the file system by using the right mouse button context menu on the folder tree, and add your project output there.

GAC setup

Now your assemblies will be registered during install.

You might also want to enable developers to easily select your assembly through the Add Reference dialog. To make this possibole you just have to tell the .NET framework where to find your public assemblies. So during installation, you might want to register the application folder or one of its subfolders by setting a default value for the following Machine level registry key.

 \Software\Microsoft\.NETFramework\AssemblyFolders\<company or application name>

Set the key value to point to the folder containing your assemblies, e.g. “[TARGETDIR]\lib\”.

That’s it!