Tuesday, March 27, 2007

How to add Microsoft Enterprise Library (June 2005) to GAC?

You may need to add the enterprise library to GAC in case that you want to share it across more than one application in a production server, the enterprise library is a set of dlls, you should sign all those dlls in order to be added to the GAC. So, you should follow the following steps:

1- open the command prompt and type "sn -k c:\mykey.snk" to generate key file which will be used to sign the assemblies.

2- Open the enterprise library solution in the Visual Studio.

3- Open the Caching Project.

4- Open the GlobalAssemblyInfo.cs shortcut in the Caching project.

5- Add the following line [assembly: AssemblyKeyFile("c:\\mykey.snk")]

6- Make sure that you don't have any "AssemblyKeyFile" attributes in the assemblyinfo.cs of each project, other wise you will get a compilation errors.

7- copy \Program Files\Common Files\System\Ole DB\oledb32.dll to c:\

8- generate the signed interop assembly using the following command: tlbimp /keyfile:c:\mykey.snk c:\oledb32.dll

9- the above command will generate "MSDASC.dll" which is the primary interop assembly for the oledb32 com

10- open the Configuration.Design Project

11- delete "MSDASC" from the references

12- add new reference to the generated signed MSDASC.dll

13- Complie the project and add all the dlls to the GAC