AssemblyFlagsAttribute 建構函式

定義

初始化 AssemblyFlagsAttribute 類別的新執行個體。Initializes a new instance of the AssemblyFlagsAttribute class.

多載

AssemblyFlagsAttribute(Int32)
已過時。
已過時。

使用轉換成整數值的指定 AssemblyFlagsAttribute 旗標組合,來初始化 AssemblyNameFlags 類別的新執行個體。Initializes a new instance of the AssemblyFlagsAttribute class with the specified combination of AssemblyNameFlags flags, cast as an integer value.

AssemblyFlagsAttribute(AssemblyNameFlags)

使用指定的 AssemblyFlagsAttribute 旗標組合,來初始化 AssemblyNameFlags 類別的新執行個體。Initializes a new instance of the AssemblyFlagsAttribute class with the specified combination of AssemblyNameFlags flags.

AssemblyFlagsAttribute(UInt32)
已過時。
已過時。

使用轉換成不帶正負號的整數值之指定 AssemblyFlagsAttribute 旗標組合,來初始化 AssemblyNameFlags 類別的新執行個體。Initializes a new instance of the AssemblyFlagsAttribute class with the specified combination of AssemblyNameFlags flags, cast as an unsigned integer value.

AssemblyFlagsAttribute(Int32)

警告

This constructor has been deprecated. Please use AssemblyFlagsAttribute(AssemblyNameFlags) instead. https://go.microsoft.com/fwlink/?linkid=14202

警告

This constructor has been deprecated. Please use AssemblyFlagsAttribute(AssemblyNameFlags) instead. http://go.microsoft.com/fwlink/?linkid=14202

使用轉換成整數值的指定 AssemblyFlagsAttribute 旗標組合,來初始化 AssemblyNameFlags 類別的新執行個體。Initializes a new instance of the AssemblyFlagsAttribute class with the specified combination of AssemblyNameFlags flags, cast as an integer value.

public:
 AssemblyFlagsAttribute(int assemblyFlags);
[System.Obsolete("This constructor has been deprecated. Please use AssemblyFlagsAttribute(AssemblyNameFlags) instead. https://go.microsoft.com/fwlink/?linkid=14202")]
public AssemblyFlagsAttribute (int assemblyFlags);
public AssemblyFlagsAttribute (int assemblyFlags);
[System.Obsolete("This constructor has been deprecated. Please use AssemblyFlagsAttribute(AssemblyNameFlags) instead. http://go.microsoft.com/fwlink/?linkid=14202")]
public AssemblyFlagsAttribute (int assemblyFlags);
[<System.Obsolete("This constructor has been deprecated. Please use AssemblyFlagsAttribute(AssemblyNameFlags) instead. https://go.microsoft.com/fwlink/?linkid=14202")>]
new System.Reflection.AssemblyFlagsAttribute : int -> System.Reflection.AssemblyFlagsAttribute
new System.Reflection.AssemblyFlagsAttribute : int -> System.Reflection.AssemblyFlagsAttribute
[<System.Obsolete("This constructor has been deprecated. Please use AssemblyFlagsAttribute(AssemblyNameFlags) instead. http://go.microsoft.com/fwlink/?linkid=14202")>]
new System.Reflection.AssemblyFlagsAttribute : int -> System.Reflection.AssemblyFlagsAttribute
Public Sub New (assemblyFlags As Integer)

參數

assemblyFlags
Int32

轉換成整數值的 AssemblyNameFlags 旗標位元組合,表示 Just-In-Time (JIT) 編譯器選項、壽命、組件是否可重定目標,以及組件是否具有完整或 Token 化的公開金鑰。A bitwise combination of AssemblyNameFlags flags, cast as an integer value, representing just-in-time (JIT) compiler options, longevity, whether an assembly is retargetable, and whether it has a full or tokenized public key.

屬性

備註

這個不具類型的函式現在已過時。This untyped constructor is now obsolete. 請勿使用。Do not use.

適用於

AssemblyFlagsAttribute(AssemblyNameFlags)

使用指定的 AssemblyFlagsAttribute 旗標組合,來初始化 AssemblyNameFlags 類別的新執行個體。Initializes a new instance of the AssemblyFlagsAttribute class with the specified combination of AssemblyNameFlags flags.

public:
 AssemblyFlagsAttribute(System::Reflection::AssemblyNameFlags assemblyFlags);
public AssemblyFlagsAttribute (System.Reflection.AssemblyNameFlags assemblyFlags);
new System.Reflection.AssemblyFlagsAttribute : System.Reflection.AssemblyNameFlags -> System.Reflection.AssemblyFlagsAttribute
Public Sub New (assemblyFlags As AssemblyNameFlags)

參數

assemblyFlags
AssemblyNameFlags

AssemblyNameFlags 旗標的位元組合,表示 Just-In-Time (JIT) 編譯器選項、壽命、組件是否可重定目標,以及組件是否具有完整或 Token 化的公開金鑰。A bitwise combination of AssemblyNameFlags flags representing just-in-time (JIT) compiler options, longevity, whether an assembly is retargetable, and whether it has a full or tokenized public key.

範例

下列程式碼範例顯示如何將套用 AssemblyFlagsAttribute 至元件,以及如何在執行時間讀取旗標。The following code example shows how to apply the AssemblyFlagsAttribute to an assembly, and how to read the flags at run time. 此範例也會建立屬性的實例,並使用 AssemblyFlags 屬性來顯示旗標。The example also creates an instance of the attribute, and uses the AssemblyFlags property to display the flags. 如需如何將套用 AssemblyFlagsAttribute 至動態元件的範例,請參閱 AssemblyName.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
*/
using System;
using System.Reflection;

// Specify a combination of AssemblyNameFlags for this
// assembly.
[assembly:AssemblyFlagsAttribute(
    AssemblyNameFlags.EnableJITcompileOptimizer |
    AssemblyNameFlags.Retargetable)]

public class Example
{
    public static void Main()
    {
        // Get this assembly.
        Assembly thisAsm = typeof(Example).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 = new AssemblyFlagsAttribute(
            AssemblyNameFlags.EnableJITcompileOptimizer |
            AssemblyNameFlags.Retargetable);

        // 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.
        Console.WriteLine();
        ListFlags(anf);
    }

    private static void ListFlags(AssemblyNameFlags anf)
    {
        if (anf == AssemblyNameFlags.None)
        {
            Console.WriteLine("AssemblyNameFlags.None");
        }
        else
        {
            if (0!=(anf & AssemblyNameFlags.Retargetable))
                Console.WriteLine("AssemblyNameFlags.Retargetable");
            if (0!=(anf & AssemblyNameFlags.PublicKey))
                Console.WriteLine("AssemblyNameFlags.PublicKey");
            if (0!=(anf & AssemblyNameFlags.EnableJITcompileOptimizer))
                Console.WriteLine("AssemblyNameFlags.EnableJITcompileOptimizer");
            if (0!=(anf & AssemblyNameFlags.EnableJITcompileTracking))
                Console.WriteLine("AssemblyNameFlags.EnableJITcompileTracking");
        }
    }
}

/* This code example produces the following output:

AssemblyNameFlags.Retargetable
AssemblyNameFlags.PublicKey
AssemblyNameFlags.EnableJITcompileOptimizer

AssemblyNameFlags.Retargetable
AssemblyNameFlags.EnableJITcompileOptimizer
*/
Imports System.Reflection

' Specify a combination of AssemblyNameFlags for this 
' assembly.
<Assembly:AssemblyFlagsAttribute( _
       AssemblyNameFlags.EnableJITcompileOptimizer _
    Or AssemblyNameFlags.Retargetable)>

Public Class Example
    Public Shared Sub Main()
        ' Get this assembly.
        Dim thisAsm As Assembly = GetType(Example).Assembly

        ' Get the AssemblyName for this assembly.
        Dim thisAsmName As AssemblyName = 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.
        Dim afa As New AssemblyFlagsAttribute( _
               AssemblyNameFlags.EnableJITcompileOptimizer _
            Or AssemblyNameFlags.Retargetable)

        ' Get the flags. The property returns an integer, so
        ' the return value must be cast to AssemblyNameFlags.
        Dim anf As AssemblyNameFlags = _
            CType(afa.AssemblyFlags, AssemblyNameFlags)

        ' Display the flags.
        Console.WriteLine()
        ListFlags(anf)
    End Sub

    Private Shared Sub ListFlags(ByVal anf As AssemblyNameFlags)

        If anf = AssemblyNameFlags.None Then
            Console.WriteLine("AssemblyNameFlags.None")
        Else
            If 0 <> (anf And AssemblyNameFlags.Retargetable) Then _
                Console.WriteLine("AssemblyNameFlags.Retargetable")
            If 0 <> (anf And AssemblyNameFlags.PublicKey) Then _
                Console.WriteLine("AssemblyNameFlags.PublicKey")
            If 0 <> (anf And AssemblyNameFlags.EnableJITcompileOptimizer) Then _
                Console.WriteLine("AssemblyNameFlags.EnableJITcompileOptimizer")
            If 0 <> (anf And AssemblyNameFlags.EnableJITcompileTracking) Then _
                Console.WriteLine("AssemblyNameFlags.EnableJITcompileTracking")
        End If

    End SUb
End Class

' This code example produces the following output:
'
'AssemblyNameFlags.Retargetable
'AssemblyNameFlags.PublicKey
'AssemblyNameFlags.EnableJITcompileOptimizer
'
'AssemblyNameFlags.Retargetable
'AssemblyNameFlags.EnableJITcompileOptimizer

另請參閱

適用於

AssemblyFlagsAttribute(UInt32)

警告

This constructor has been deprecated. Please use AssemblyFlagsAttribute(AssemblyNameFlags) instead. https://go.microsoft.com/fwlink/?linkid=14202

警告

This constructor has been deprecated. Please use AssemblyFlagsAttribute(AssemblyNameFlags) instead. http://go.microsoft.com/fwlink/?linkid=14202

重要

此 API 不符合 CLS 規範。

符合 CLS 規範替代方案
System.Reflection.AssemblyFlagsAttribute.AssemblyFlagsAttribute(AssemblyNameFlags)

使用轉換成不帶正負號的整數值之指定 AssemblyFlagsAttribute 旗標組合,來初始化 AssemblyNameFlags 類別的新執行個體。Initializes a new instance of the AssemblyFlagsAttribute class with the specified combination of AssemblyNameFlags flags, cast as an unsigned integer value.

public:
 AssemblyFlagsAttribute(System::UInt32 flags);
[System.CLSCompliant(false)]
[System.Obsolete("This constructor has been deprecated. Please use AssemblyFlagsAttribute(AssemblyNameFlags) instead. https://go.microsoft.com/fwlink/?linkid=14202")]
public AssemblyFlagsAttribute (uint flags);
public AssemblyFlagsAttribute (uint flags);
[System.CLSCompliant(false)]
[System.Obsolete("This constructor has been deprecated. Please use AssemblyFlagsAttribute(AssemblyNameFlags) instead. http://go.microsoft.com/fwlink/?linkid=14202")]
public AssemblyFlagsAttribute (uint flags);
[System.CLSCompliant(false)]
public AssemblyFlagsAttribute (uint flags);
[<System.CLSCompliant(false)>]
[<System.Obsolete("This constructor has been deprecated. Please use AssemblyFlagsAttribute(AssemblyNameFlags) instead. https://go.microsoft.com/fwlink/?linkid=14202")>]
new System.Reflection.AssemblyFlagsAttribute : uint32 -> System.Reflection.AssemblyFlagsAttribute
new System.Reflection.AssemblyFlagsAttribute : uint32 -> System.Reflection.AssemblyFlagsAttribute
[<System.CLSCompliant(false)>]
[<System.Obsolete("This constructor has been deprecated. Please use AssemblyFlagsAttribute(AssemblyNameFlags) instead. http://go.microsoft.com/fwlink/?linkid=14202")>]
new System.Reflection.AssemblyFlagsAttribute : uint32 -> System.Reflection.AssemblyFlagsAttribute
[<System.CLSCompliant(false)>]
new System.Reflection.AssemblyFlagsAttribute : uint32 -> System.Reflection.AssemblyFlagsAttribute
Public Sub New (flags As UInteger)

參數

flags
UInt32

轉換成不帶正負號的整數值之 AssemblyNameFlags 旗標位元組合,表示 Just-In-Time (JIT) 編譯器選項、壽命、組件是否可重定目標,以及組件是否具有完整或 Token 化的公開金鑰。A bitwise combination of AssemblyNameFlags flags, cast as an unsigned integer value, representing just-in-time (JIT) compiler options, longevity, whether an assembly is retargetable, and whether it has a full or tokenized public key.

屬性

備註

這個不具類型的函式現在已過時。This untyped constructor is now obsolete. 請勿使用。Do not use.

適用於