As we want to share our library across multiple web applications we must register the assembly that holds the code behind of our user control in the GAC (Global Assembly Cache). In order to register our assembly in the GAC we must follow several steps.
First, generate a strong name key for it and set the "AssemblyKeyFile" attribute in the "assemblyInfo.cs" of our project with the keys filename and path. We can generate a key using the DOS sn.exe utility.
|sn.exe -k ControlsLibraryKeys.snk|
Next, we build our solution and to register our assembly in the gac we choose to either drag and drop it directly in the \WINNT\assembly folder or use the following DOS command.
|Gacutil.exe -i yourassemblypath|
We must also inform the ASPX compiler that we want him to check for our new shared assembly. To do that we need to edit the machine.config. This file contains most .Net configuration of our local machine. You can find it in the following directory:
Load the file in a plain text editor and search for the <assemblies> element, add the following child element to it :
|<add assembly="UserControlsLibrary, Version=184.108.40.206, Culture=neutral, PublicKeyToken=29f4c43ca2dde360"/>|
These values might change depending on your current settings. You can get the current publicKeyToken of your assembly from the \WINNT\assembly folder.