-keycontainer (C# Compiler Options)

Specifies the name of the cryptographic key container.




The name of the strong name key container.


When the -keycontainer option is used, the compiler creates a sharable component. The compiler inserts a public key from the specified container into the assembly manifest and signs the final assembly with the private key. To generate a key file, type sn -k file at the command line. sn -i installs the key pair into a container. This option is not supported when the compiler runs on CoreCLR. To sign an assembly when building on CoreCLR, use the -keyfile option.

If you compile with -target:module, the name of the key file is held in the module and incorporated into the assembly when you compile this module into an assembly with -addmodule.

You can also specify this option as a custom attribute (System.Reflection.AssemblyKeyNameAttribute) in the source code for any Microsoft intermediate language (MSIL) module.

You can also pass your encryption information to the compiler with -keyfile. Use -delaysign if you want the public key added to the assembly manifest but want to delay signing the assembly until it has been tested.

For more information, see Creating and Using Strong-Named Assemblies and Delay Signing an Assembly.

To set this compiler option in the Visual Studio development environment

  1. This compiler option is not available in the Visual Studio development environment.

You can programmatically access this compiler option with AssemblyKeyContainerName.

See also