How to: Sign an Assembly (Visual Studio)

Assembly signing (also called strong-name signing) gives an application or component a unique identity that other software can use to identify and refer explicitly to it. A strong name consists of its simple text name, version number, culture information (if provided), plus a public/private key pair. This information is stored in a key file; this can be a Personal Information Exchange (PFX) file or a certificate from the current user's Windows certificate store. For more information, see Strong-Name Signing for Managed Applications.

Note

This topic applies to Visual C# and Visual Basic projects only. For information about how to sign assemblies in Visual C++ projects, see Strong Name Assemblies (Assembly Signing) (C++/CLI).

For the purpose of assembly signing, Visual Studio supports only Personal Information Exchange (.pfx) and Strong Name Key (.snk) files stored in the project system on the local computer.

In some cases, you may only have access to a public key. If so, you can use delay signing to defer assigning the private key. For more information, see How to: Delay Sign an Assembly (Visual Studio).

You can sign your assembly using the options in the Signing page of the Project Designer as follows; for more information, see Signing Page, Project Designer.

The following procedures apply to signing the assembly only. If you want to sign the application and deployment manifests, see How to: Sign Application and Deployment Manifests.

To sign an assembly using a new key file

  1. With the project node selected in Solution Explorer, from the Project menu, click Properties (or right-click the project node in Solution Explorer, and click Properties).

  2. In the Project Designer, click the Signing tab.

  3. Select the Sign the assembly check box.

  4. Specify a new key file. In the Choose a strong name key file drop-down list, select <New...>. Note that new key files are always created in the .pfx format.

    The Create Strong Name Key Dialog Box appears.

  5. In the Create Strong Name Key dialog box, enter a name and password for the new key file, and then click OK.

    Note

    Optionally, you can enable delay signing by selecting the Delay sign only check box. For more information, see How to: Delay Sign an Assembly (Visual Studio).

To sign an assembly using an existing key file

  1. With the project node selected in Solution Explorer, from the Project menu, click Properties (or right-click the project node in Solution Explorer, and click Properties).

  2. In the Project Designer, click the Signing tab.

  3. Select the Sign the assembly check box.

  4. Specify an existing key file. In the Choose a strong name key file drop-down list, select <Browse...>.

  5. In the Select File dialog box, navigate to the key file or enter its path in the File name box; then click Open to select it. (For more information, see How to: Create a Public/Private Key Pair.)

    Note

    You can change the password for the key file by clicking Change Password. In the Change Key Password Dialog Box, enter the old password, and then enter the new password twice.

    Note

    Optionally, you can enable delay signing by selecting the Delay sign only check box. For more information, see How to: Delay Sign an Assembly (Visual Studio).

See Also

Tasks

How to: Delay Sign an Assembly (Visual Studio)

Concepts

Strong-Name Signing for Managed Applications

Other Resources

Managing Assembly and Manifest Signing