Assembly strong signature knowledge learned from compiling Dotnetopenauth

Source: Internet
Author: User

1. Background

A recent study in Dotnetopenauth--oauth, a. NET open source implementation, official website: http://dotnetopenauth.net/.

The source code for Dotnetopenauth from GitHub has found that the latest version is up to 5.1, and the version released in NuGet is only 4.3. The new version uses the. NET 4.5 asynchronous feature (async, await) and decides to use the latest edition directly.

With the latest version, you need to compile yourself. Compiling with Visual Studio 2012 opens the solution file, one compilation succeeded, but there are 20 compiled Dotnetopenauth related DLLs, and so many DLLs are inconvenient to reference. Discovery Dotnetopenauth provides an MSBuild configuration file that can be automatically merged (using Ilmerge) at compile time. The MSBuild command is then compiled instead.

2. Using MSBuild for the first time compilation

2.1. Using the Dotnetopenauth tools\drop.proj compile configuration file, the following content is commented to speed up the compilation:

<!--<ItemGroup>
    <projectstobuild include= "$ (projectroot) samples\samples.proj" >
        < properties>targetframeworkversion=v4.5</properties>
    </ProjectsToBuild>
    
    --><!-- Sandcastle doesn ' t seem to is able to handle. NET 4.0. --><!--
    <projectstobuild include= "$ (projectroot) doc\doc.proj" >
        <Properties> targetframeworkversion=v4.5</properties>
    </ProjectsToBuild>
</ItemGroup>-->

2.2. Run VS2012 command line: Developer command Prompt for VS2012

2.3. Run MSBuild Command:

MSBuild Tools/drop.proj

2.4. Successful compilation

2.5. The merged DotNetOpenAuth.dll is obtained in the Drops\v4.5\debug folder.

3. Test the compiled Dotnetopenauth

3.1. Refer to the compiled DotNetOpenAuth.dll in another project

3.2. After compiling the project, an error message appears:

Could not load file or assembly ' Dotnetopenauth ' or one of its dependencies. The strong name signature could is verified. The Assembly may have been tampered with, or it is delay signed the but not fully with the signed private key. (Exception from hresult:0x80131045)

From this error message you can read: A strong signature is required for the Dotnetopenauth.

4. MSBuild compilation with strong signatures

4.1. Generate Public key

Generating the public key requires the help of Sn.exe (SN is the abbreviation for Strong name), which is a tool that is brought in the Visual Studio/windows SDK. Running the Sn.exe command requires entering developer command Prompt for VS2012.

The specific steps are as follows:

4.1.1. Generate a key pair (public/private key) and save to a. pfx file

Sn-k mykeyfile.pfx

4.1.2. To install a key pair from a file into a key container

Sn-i mykeyfile.pfx Mykeycontainer

4.1.3. Export the public key to the. pub file from the. pfx file that holds the key pair

Sn-p mykeyfile.pfx mykeyfile.pub

4.1.4. Displays the public key stored in the. pub file

Sn-q-T Mykeyfile.pub

4.2. Using the generated public key for MSBuild compilation

msbuild/p:keypaircontainer=mykeycontainer,publickeyfile= "<full path>mykeyfile.pub" tools/drop.proj

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.