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
/** @attribute ComVisibleAttribute(true) */ 
/** @attribute AttributeUsageAttribute(AttributeTargets.Assembly, Inherited=false) */ 
public final class AssemblyFlagsAttribute extends Attribute
AttributeUsageAttribute(AttributeTargets.Assembly, Inherited=false) 
public final class AssemblyFlagsAttribute extends Attribute
Not applicable.

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

Community Additions