AssemblyFlagsAttribute::AssemblyFlags Property
Gets an integer value representing the combination of AssemblyNameFlags flags specified when this attribute instance was created.
Assembly: mscorlib (in mscorlib.dll)
Property Value
Type: System::Int32An integer value representing a bitwise combination of AssemblyNameFlags flags.
This property returns an integer for backward compatibility. Cast the value to the AssemblyNameFlags type before using it.
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 namespace System; using namespace System::Reflection; // Specify a combination of AssemblyNameFlags for this // assembly. [assembly:AssemblyFlagsAttribute( AssemblyNameFlags::EnableJITcompileOptimizer | AssemblyNameFlags::Retargetable)]; public ref class Example { public: static void Main() { // Get this assembly. Assembly^ thisAsm = Example::typeid->Assembly; // Get the AssemblyName for this assembly. AssemblyName^ thisAsmName = thisAsm->GetName( false ); // Display the flags that were set for this assembly. ListFlags( thisAsmName->Flags ); // 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 = gcnew AssemblyFlagsAttribute( static_cast<AssemblyNameFlags> (AssemblyNameFlags::EnableJITcompileOptimizer | AssemblyNameFlags::Retargetable) ); // Get the flags. The property returns an integer, so // the return value must be cast to AssemblyNameFlags. AssemblyNameFlags anf = static_cast<AssemblyNameFlags>(afa->AssemblyFlags); // Display the flags. Console::WriteLine(); ListFlags( anf ); } private: static void ListFlags( AssemblyNameFlags anf ) { if ( anf == AssemblyNameFlags::None ) { Console::WriteLine( L"AssemblyNameFlags.None" ); } else { if ( 0 != static_cast<Int32>(anf & AssemblyNameFlags::Retargetable) ) Console::WriteLine( L"AssemblyNameFlags.Retargetable" ); if ( 0 != static_cast<Int32>(anf & AssemblyNameFlags::PublicKey) ) Console::WriteLine( L"AssemblyNameFlags.PublicKey" ); if ( 0 != static_cast<Int32>(anf & AssemblyNameFlags::EnableJITcompileOptimizer) ) Console::WriteLine( L"AssemblyNameFlags.EnableJITcompileOptimizer" ); if ( 0 != static_cast<Int32>(anf & AssemblyNameFlags::EnableJITcompileTracking) ) Console::WriteLine( L"AssemblyNameFlags.EnableJITcompileTracking" ); } } }; int main() { Example::Main(); } /* This code example produces the following output: AssemblyNameFlags.Retargetable AssemblyNameFlags.PublicKey AssemblyNameFlags.EnableJITcompileOptimizer AssemblyNameFlags.Retargetable AssemblyNameFlags.EnableJITcompileOptimizer */
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1