VS. NET re-build a strong-name assembly

Source: Internet
Author: User

If an Assembly is to be encapsulated as an ActiveX/COM component, it must have a Strong Name (Strong Name), that is, you must specify the SNK (Strong Name Key) during compilation ). However, if an Assembly is compiled with a strong name, it requires that all other assemblies referenced by it must have a strong name. Otherwise, compilation cannot be successful. In this case, you can create or recreate a named assembly as follows.
First, whether we need a key pair (take VS2008 as an example ): 1. Run in "Start Menu"-"program"-"Microsoft Visual Studio 2008"-"Visual Studio Tools"-"Visual Studio 2008 command prompt" (Use this command line to work to execute the VS command line tool in any path ); 2. Create a strongly-named Assembly key file and execute the command C: \ sn-k keypair. snk 3. Bind a key file to the class library (1). if you have the source code of the class library to be referenced, you can find AssemblyInfo in the class library project. add the following attributes to the cs source file: [assembly: AssemblyKeyFile ("C: \ keypair. snk ")] (if the source code is available, you can also directly use the project configuration to directly generate and bind a key pair to the class library project. Configuration example: Right-click "Class Library Project"-> "properties"-> "signature" tab-> select the "sign for assembly" check box-> select a strong name key file (K): "drop-down box->" new "or" browse "to select an existing key file .)
B. Generate a project to obtain a type library with a strong name. (2) If you only have a third-party class library (xxxxxx. dll) file and no source code project, continue with the following operations.
A. Use the class library file to obtain the Microsoft intermediate language (MSIL) source code file.
C: \> ildasm xxxxxx. dll/out: xxxxxx. il B. use the MSIL source code file (xxxxxx. il) and the newly generated (keypair. snk) key file to create a new Assembly class library file C: \> ilasm xxxxxx. il/dll/key = keypair. snk

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.