strong name in gac

After creating an assembly and before registering it to the Global Assembly Cache the first thing that is required is to assign a strong name to the assembly. What is a strong name? Well! a strong name is basically assigned to an assembly or a component to distinguish it from other assemblies and components existing in the GAC. A strong name consists of an assembly identity (name, version, etc.), public key and a digital signature. The Global Assembly Cache is used to share assemblies throughout applications. For example, to create a strong name for an assembly named as sample.dll, you would write on the command prompt. sn -k sample.snk This would generate a strong name key pair and store it in a file named as sample.snk. The extension of the file can be anything, but mostly .snk is used as a convention. The -k option here is for creating a strong name key pair. There are other options also available which you could search for in MSDN. After generating the strong name key pair file, it is required to associate this file with our assembly, for doing that you have to add the following lines in the code of your assembly. Imports System.Reflection Note here that the information regarding the file containing the strong name key pair is placed in the code file before the namespace declaration. Also you are required to import the System.Reflection namespace in order for the statement to work, otherwise the compiler would be showing you an error stating that it does not recognize the statement. After compiling the assembly with the statements, containing the strong name information being added to it, you now have to place the assembly into the GAC. You can either do it manually by simply copying and pasting the assembly into the GAC, which is located at c:\winnt\assembly; or use gacutil , gacutil /i sample.dll please refer to below link for more info, http://aspalliance.com/394_Installing_an_Assembly_in_GAC
posted @ 2010-04-02 10:09  半克拉鹅卵石  阅读(223)  评论(0编辑  收藏  举报