Export (0) Print
Expand All
2 out of 2 rated this helpful - 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

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 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC, Xbox 360, Zune

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 3.5, 2.0, 1.0

XNA Framework

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

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.