Enterprise Library assemblies are not strong named
You need to sign the enterprise library assemblies if you want to install it into the GAC/ to add a reference to a strong named assembly.
In this article I will explain how to delay sign your Enterprise Library assemblies and use it with a strong named assembly.
In this article I will explain the entire process of strong naming the enterprise library assemblies with details that may help the users using Enterprise Library in their applications.
Using the Strong Naming Guidance Package
- Open the EntrpriseLibrary.VSTS solution in Visual Studio.
- Ensure that you have GAX and Strong naming guidance package installed on your system.
- On Visual Studio select Tools->Guidance Package Manager
- Select 'Enable/ Disable Guidance Packages'
- Select the Strong Naming Guidance packages.
- Right-click on a project/ solution folder and choose "Create a new strong-name key pair file". This will create a string name key file for signing the assemblies.
- Right-click on the project/ solution folder and choose "Strong-name all projects in this solution or solution folder".
- Use the key file created in step 6 for strong naming the assemblies. Also select the "Update InternalsVisibleTo" checkbox to tell the recipe to search for this attribute and add the public key.
- Press OK and the strong name guidance package will do the rest for you.
- Open the visual studio command prompt and create a strong name key file.
- Extract the public key file from the strong name file.
- Use sn-tp to see the hex decimal form of the public key from the public key file, and copy the hex key to a notepad for later use.
- Now open the enterprise library source code and then delay sign the projects using the public key file. For that right click the project and select Add Existing Item
- Open the folder where the public key file is stored. Select the public key file and click on Add as link in the dialog box. This will add the reference to the key file.
- Right click the project and select properties.
- On the signing tab check the Sign the assembly check box and select the public key file name displayed in the drop down list.
- Check the delay sign only check box also.
- Now search for “InternalsVisibleTo” in the entire solution and add the PublicKey= option to the attribute. (Use the hex value that is copied in step 3 for this) Eg: [assembly: InternalsVisibleTo("Microsoft.Practices.EnterpriseLibrary.Caching.Tests,
- Now rebuild the entire solution.
- Use the sn-Vr option to skip verification for the assemblies.