Steps:
1. First create the Class library project, complete the coding;
2. Generate a strong name for the class library project and generate a key file, which is an encrypted hash key or signature. This strong name ensures correct version control of the component. This helps prevent components with the same name from conflicting or misused by consuming applications)
Use the SN tool in the. NET Framework development package to generate an encryption key pair, for example: Create a folder in D disk: GACkey, and then execute on the command line: Sn-k "D:\GACkey\GACkey.snk" in D:\GACkey\ GACKEY.SNK will generate the key file;
3. Association class library files and key files, and compile and build DLL files (there are two methods);
A.
Double-click the AssemblyInfo.cs file in Visual Studio. NET Solution Explorer. This file has a list of assembly attributes that will be included by default when you create projects in Visual Studio. NET. Modify the "AssemblyKeyFile" assembly property in your code, as follows:
[Assembly:assemblykeyfile ("Path of key file (" D:\GACkey\GACkey.snk ")]
Compile the project by pressing Ctrl+shift+b.
B.
1. On the Project menu, click the Class library item properties.
2. On the Signature tab, click to select the check box to sign the assembly.
3. In selecting a strong name key file, click New < >.
4. In the Create Strong Name Key dialog box, click to select the Password protected check box for my key file.
5. In the key File name box, type the name of the key file.
6. In the Enter Password box, type the password you want to use.
7. In the Confirm Password box, type the same password and click OK.
Note We recommend that you always use a password when creating a key file. Always create a new key file in the. pfx file format is password protected.
8. Compile the project, press CTRL + SHIFT + B.
Note There is no additional code required to install the. dll file in the global assembly cache.
4. Install the DLL or assembly into the GAC (there are two ways);
A. Installing through the Gacutil tool in the SDK
Execute command line: Gacutil-i "path to DLL file"
B. Drag the file directly to the C:\[systemroot]\assembly folder by locating the DLL file;
5. Verify that the assembly is installed in the global assembly cache
You can use the GlobalAssemblyCache tool to verify that an assembly is installed in the global assembly cache. Step action:
1. Click Start, click Run, type cmd and then click OK.
2. Instead of installing the. NET Framework SDK, the directory's current working directory uses one of the following commands: • if installed. NETFramework 2.0 SDK, type the following command, and then press ENTER:
CD "%ProgramFiles%\Microsoft Visual Studio 8\sdk\v2.0\\bin"
• If the. NET Framework 1.1 SDK is installed, type the following command, and then press ENTER:
CD "%programfiles%\microsoft.net\sdk\v1.1\bin"
3. Use the GlobalAssemblyCache tool to display the assembly you just created and install the information. To do this, type the following command at the command prompt, and then press ENTER:
Gacutil-l "assembly name"
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.