Udostępnij za pośrednictwem


/KEYFILE (Specify Key or Key Pair to Sign an Assembly)

/KEYFILE:filename

Remarks

where:

  • filename
    File that contains the key. Place the string in double quotation marks (" ") if it contains a space.

Remarks

The linker inserts the public key into the assembly manifest and then signs the final assembly with the private key. To generate a key file, type sn -k file at the command line. A signed assembly is said to have a strong name.

If you compile with /LN, the name of the key file is held in the module and incorporated into the assembly that is created when you compile an assembly that includes an explicit reference to the module, via #using, or when linking with /ASSEMBLYMODULE.

You can also pass your encryption information to the linker with /KEYCONTAINER. Use /DELAYSIGN if you want a partially signed assembly. See Strong Name Assemblies (Assembly Signing) (C++/CLI) for more information on signing an assembly.

In case both /KEYFILE and /KEYCONTAINER are specified (either by command line option or by custom attribute), the linker will first try the key container. If that succeeds, then the assembly is signed with the information in the key container. If the linker does not find the key container, it will try the file specified with /KEYFILE. If that succeeds, the assembly is signed with the information in the key file and the key information will be installed in the key container (similar to sn -i) so that on the next compilation, the key container will be valid.

Note that a key file might contain only the public key.

See Creating and Using Strong-Named Assemblies for more information on signing an assembly.

Other linker options that affect assembly generation are:

To set this linker option in the Visual Studio development environment

  1. Open the project's Property Pages dialog box. For details, see Setting Visual C++ Project Properties.

  2. Click the Linker folder.

  3. Click the Command Line property page.

  4. Type the option into the Additional Options box.

To set this linker option programmatically

See Also

Reference

Setting Linker Options

Linker Options