AssemblyFlagsAttribute 建構函式
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
初始化 AssemblyFlagsAttribute 類別的新執行個體。
多載
| 名稱 | Description |
|---|---|
| AssemblyFlagsAttribute(Int32) |
已淘汰.
已淘汰.
已淘汰.
初始化一個新的類別實例 AssemblyFlagsAttribute ,使用指定的旗標組合 AssemblyNameFlags ,並以整數值鑄造。 |
| AssemblyFlagsAttribute(AssemblyNameFlags) |
初始化一個新的類別實例 AssemblyFlagsAttribute ,使用指定的旗標組合 AssemblyNameFlags 。 |
| AssemblyFlagsAttribute(UInt32) |
已淘汰.
已淘汰.
已淘汰.
初始化一個新的類別實例 AssemblyFlagsAttribute ,使用指定的旗標組合 AssemblyNameFlags ,並以無符號整數值鑄造。 |
AssemblyFlagsAttribute(Int32)
警告
This constructor has been deprecated. Use AssemblyFlagsAttribute(AssemblyNameFlags) instead.
警告
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 ,並以整數值鑄造。
public:
AssemblyFlagsAttribute(int assemblyFlags);
[System.Obsolete("This constructor has been deprecated. Use AssemblyFlagsAttribute(AssemblyNameFlags) instead.")]
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);
[System.Obsolete("This constructor has been deprecated. Please use AssemblyFlagsAttribute(AssemblyNameFlags) instead. http://go.microsoft.com/fwlink/?linkid=14202")]
public AssemblyFlagsAttribute(int assemblyFlags);
public AssemblyFlagsAttribute(int assemblyFlags);
[<System.Obsolete("This constructor has been deprecated. Use AssemblyFlagsAttribute(AssemblyNameFlags) instead.")>]
new System.Reflection.AssemblyFlagsAttribute : int -> System.Reflection.AssemblyFlagsAttribute
[<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
[<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
new System.Reflection.AssemblyFlagsAttribute : int -> System.Reflection.AssemblyFlagsAttribute
Public Sub New (assemblyFlags As Integer)
參數
- assemblyFlags
- Int32
一個以整數值形式轉換的旗標, AssemblyNameFlags 代表即時(JIT)編譯器的選項、存續時間、組合語言是否可重新定位,以及其公鑰是否完整或標記化。
- 屬性
備註
這個未型別的建構器現已過時。 請勿使用。
適用於
AssemblyFlagsAttribute(AssemblyNameFlags)
初始化一個新的類別實例 AssemblyFlagsAttribute ,使用指定的旗標組合 AssemblyNameFlags 。
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 的旗標,代表即時(JIT)編譯器的選項、壽命、組合語言是否可重新導向,以及其是否擁有完整或標記化的公鑰。
範例
以下程式碼範例說明如何將 套 AssemblyFlagsAttribute 用到 assembly 中,以及如何在執行時讀取旗標。 範例同時建立了屬性的實例,並利用該 AssemblyFlags 屬性來顯示旗標。 關於如何將 應用AssemblyFlagsAttribute於動態裝配的範例,請參見屬性。AssemblyName.Flags
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. Use AssemblyFlagsAttribute(AssemblyNameFlags) instead.
警告
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 規範。
初始化一個新的類別實例 AssemblyFlagsAttribute ,使用指定的旗標組合 AssemblyNameFlags ,並以無符號整數值鑄造。
public:
AssemblyFlagsAttribute(System::UInt32 flags);
[System.CLSCompliant(false)]
[System.Obsolete("This constructor has been deprecated. Use AssemblyFlagsAttribute(AssemblyNameFlags) instead.")]
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")]
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. Use AssemblyFlagsAttribute(AssemblyNameFlags) instead.")>]
new System.Reflection.AssemblyFlagsAttribute : uint32 -> System.Reflection.AssemblyFlagsAttribute
[<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
[<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 的旗標,鑄造為無符號整數值,代表即時(JIT)編譯器的選項、存續時間、組合語言是否可重新定位,以及其公鑰是否完整或標記化。
- 屬性
備註
這個未型別的建構器現已過時。 請勿使用。