AssemblyKeyFileAttribute
Class
Definition
Specifies the name of a file containing the key pair used to generate a strong name.
[System.AttributeUsage(System.AttributeTargets.Assembly, Inherited=false)]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class AssemblyKeyFileAttribute : Attribute
- Inheritance
- Attributes
Inherited Members
System.Attribute
System.Object
Examples
The following code example shows the use of the AssemblyDelaySignAttribute attribute with the AssemblyKeyFileAttribute. To compile this example, you must create a strong-name key file named TestPublicKey.snk using the Sn.exe (Strong Name Tool):
sn -k TestPublicKey.snk
Compile the example as a .dll. If you compile from the command line, use the /t:library option for C# or Visual Basic, or the /LD linker option for Visual C++.
using namespace System;
using namespace System::Reflection;
[assembly:AssemblyKeyFileAttribute("TestPublicKey.snk")];
[assembly:AssemblyDelaySignAttribute(true)];
namespace DelaySign
{
public ref class Test { };
}
using System;
using System.Reflection;
[assembly:AssemblyKeyFileAttribute("TestPublicKey.snk")]
[assembly:AssemblyDelaySignAttribute(true)]
namespace DelaySign
{
public class Test { }
}
Imports System
Imports System.Reflection
<assembly:AssemblyDelaySignAttribute(true)>
<assembly:AssemblyKeyFileAttribute("TestPublicKey.snk")>
Namespace DelaySign
Public class Test
End Class
End Namespace
Remarks
When building a strong-named assembly, the author must supply either this attribute or AssemblyKeyNameAttribute. If AssemblyDelaySignAttribute has also been specified, it is likely that this file will only contain the public key.
An example of the syntax is [assembly:AssemblyKeyFileAttribute("myKey.snk")].
Caution
Since the path and file name persist, ensure that the string you use with AssemblyKeyFileAttribute does not contain sensitive information.
Constructors
| AssemblyKeyFileAttribute(String) |
Initializes a new instance of the |
Properties
| KeyFile |
Gets the name of the file containing the key pair used to generate a strong name for the attributed assembly. |