This documentation is archived and is not being maintained.

AssemblyFlagsAttribute Class

Specifies a bitwise combination of AssemblyNameFlags flags for an assembly, describing just-in-time (JIT) compiler options, whether the assembly is retargetable, and whether it has a full or tokenized public key. This class cannot be inherited.

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

[AttributeUsageAttribute(AttributeTargets.Assembly, Inherited = false)]
public sealed class AssemblyFlagsAttribute : Attribute

The AssemblyNameFlags enumeration describes the assembly characteristics that can be set using this attribute.

To access the flags that have been specified for an assembly, use the Assembly.GetName property to obtain an AssemblyName object, then use the AssemblyName.Flags property to obtain an AssemblyNameFlags value.

To specify AssemblyNameFlags flags for a dynamic assembly, set the AssemblyName.Flags property of the AssemblyName object that you pass to the AppDomain.DefineDynamicAssembly method.

The following code example shows how to apply the AssemblyFlagsAttribute to an assembly, and how to read the flags at run time. The example also creates an instance of the attribute, and uses the AssemblyFlags property to display the flags. For an example of how to apply the AssemblyFlagsAttribute to a dynamic assembly, see the AssemblyName.Flags property.

using System;
using System.Reflection;

// Specify a combination of AssemblyNameFlags for this  
// assembly.
    AssemblyNameFlags.EnableJITcompileOptimizer |

public class Example
    public static void Main()
        // Get the currently executing assembly, which is this 
        // assembly.
        Assembly thisAsm = Assembly.GetExecutingAssembly();

        // Get the AssemblyName for the currently executing 
        // assembly.
        AssemblyName thisAsmName = thisAsm.GetName(false);

        // Display the flags that were set for this assembly.

        // Create an instance of AssemblyFlagsAttribute with the 
        // same combination of flags that was specified for this 
        // assembly. Note that PublicKey is included automatically 
        // for the assembly, but not for this instance of 
        // AssemblyFlagsAttribute.
        AssemblyFlagsAttribute afa = new AssemblyFlagsAttribute(
            AssemblyNameFlags.EnableJITcompileOptimizer |

        // Get the flags. The property returns an integer, so 
        // the return value must be cast to AssemblyNameFlags.
        AssemblyNameFlags anf = (AssemblyNameFlags) afa.AssemblyFlags;

        // Display the flags.

    private static void ListFlags(AssemblyNameFlags anf)
        if (anf == AssemblyNameFlags.None)
            if (0!=(anf & AssemblyNameFlags.Retargetable)) 
            if (0!=(anf & AssemblyNameFlags.PublicKey)) 
            if (0!=(anf & AssemblyNameFlags.EnableJITcompileOptimizer)) 
            if (0!=(anf & AssemblyNameFlags.EnableJITcompileTracking)) 

/* This code example produces the following output:




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