Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

AssemblyKeyFileAttribute Class

Specifies the name of a file containing the key pair used to generate a strong name.

Namespace: System.Reflection
Assembly: mscorlib (in mscorlib.dll)

[AttributeUsageAttribute(AttributeTargets.Assembly, Inherited=false)] 
[ComVisibleAttribute(true)] 
public sealed class AssemblyKeyFileAttribute : Attribute
/** @attribute AttributeUsageAttribute(AttributeTargets.Assembly, Inherited=false) */ 
/** @attribute ComVisibleAttribute(true) */ 
public final class AssemblyKeyFileAttribute extends Attribute
AttributeUsageAttribute(AttributeTargets.Assembly, Inherited=false) 
ComVisibleAttribute(true) 
public final class AssemblyKeyFileAttribute extends Attribute
Not applicable.

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 noteCaution:

Since the path and file name persist, ensure that the string you use with AssemblyKeyFileAttribute does not contain sensitive information.

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 Strong Name Tool (Sn.exe):

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 System;
using System.Reflection;

[assembly:AssemblyKeyFileAttribute("TestPublicKey.snk")]
[assembly:AssemblyDelaySignAttribute(true)]

namespace DelaySign
{
	public class Test { }
}

System.Object
   System.Attribute
    System.Reflection.AssemblyKeyFileAttribute
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

XNA Framework

Supported in: 1.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.