AssemblySignatureKeyAttribute 類別


從舊的、較簡單的強式名稱金鑰移轉到具有較強的雜湊演算法、較大的金鑰。Provides migration from an older, simpler strong name key to a larger key with a stronger hashing algorithm.

public ref class AssemblySignatureKeyAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Assembly, AllowMultiple=false, Inherited=false)]
public sealed class AssemblySignatureKeyAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Assembly, AllowMultiple=false, Inherited=false)>]
type AssemblySignatureKeyAttribute = class
    inherit Attribute
Public NotInheritable Class AssemblySignatureKeyAttribute
Inherits Attribute


新的較大索引鍵是簽章金鑰。The new larger key is the signature key. 在 .NET Framework 4.5 之前的版本中,簽章金鑰與身分識別金鑰相同。In versions before the .NET Framework 4.5, the signature key was identical to the identity key. 從 .NET Framework 4.5 開始,此 AssemblySignatureKeyAttribute 屬性可讓元件中繼資料繼續擁有舊的公開金鑰 token 和二進位大型物件 (BLOB) ,讓現有的元件參考繼續運作。Starting with the .NET Framework 4.5, the AssemblySignatureKeyAttribute attribute allows the assembly metadata to continue to have the old public key token and binary large object (BLOB) so that existing assembly references continue to work. 它也可確保對應來自身分識別金鑰的擁有者。It also ensures that the mapping comes from an owner of the identity key.

屬性存在時,不一定表示會進行強式名稱驗證。The presence of the attribute does not necessarily mean that strong name validation takes place. 在常見的完全信任案例中,絕對不會考慮屬性,因為強式名稱簽章永遠不會經過驗證。In common full-trust scenarios, the attribute is never considered, because strong name signatures are never validated. 不過,當必須驗證強式名稱簽章時,必須驗證強式名稱簽章和副署。However, when the strong name signature does have to be validated, both the strong name signature and the countersignature must be validated. 元件的身分識別金鑰不一定要與簽章金鑰相同, (用來執行實際簽署和驗證) 的金鑰。The assembly's identity key does not have to be identical to the signature key (the key used to do the actual signing and validation). 身分識別金鑰可以對應至不同 (更健全的) 簽署金鑰。The identity key can be mapped to a different (more robust) signing key. 這可讓您設定元件的身分識別,並將簽署金鑰和演算法更新為更安全的版本。This lets you set the identity of an assembly, and update the signing keys and algorithms to more secure versions.

當惡意元件宣告一些其他身分識別時,副署會解決安全性問題。The countersignature addresses security concerns when a malicious assembly claims some other identity. 例如,惡意的 System.Core.dll 元件可能會在其中繼資料中包含 Microsoft 公開金鑰,而且如果沒有副署,請使用屬性來指示強式名稱驗證使用攻擊者的簽章金鑰。For example, a malicious System.Core.dll assembly could contain the Microsoft public key in its metadata, and use the attribute to tell strong name validation to use the attacker's signature key if no countersignature is present. 因此,它可以偽裝為強式名稱驗證的 Microsoft 元件。Thus, it could masquerade as a strong name-validated Microsoft assembly.

如需有關如何使用這個新屬性簽署元件的詳細資訊,請參閱 增強型強式命名For information about how to sign assemblies for use with this new attribute, see Enhanced Strong Naming.


AssemblySignatureKeyAttribute(String, String)

使用指定的公開金鑰和副署,建立 AssemblySignatureKeyAttribute 類別的新執行個體。Creates a new instance of the AssemblySignatureKeyAttribute class by using the specified public key and countersignature.



取得這個組件的強式名稱副署。Gets the countersignature for the strong name for this assembly.


取得用來簽署組件之強式名稱的公開金鑰。Gets the public key for the strong name used to sign the assembly.


在衍生類別中實作時,取得這個 Attribute 的唯一識別碼。When implemented in a derived class, gets a unique identifier for this Attribute.

(繼承來源 Attribute)



傳回值,這個值指出此執行個體是否與指定的物件相等。Returns a value that indicates whether this instance is equal to a specified object.

(繼承來源 Attribute)

傳回這個執行個體的雜湊碼。Returns the hash code for this instance.

(繼承來源 Attribute)

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)

在衍生類別中覆寫時,表示這個執行個體的值是衍生類別的預設值。When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class.

(繼承來源 Attribute)

在衍生類別中覆寫時,會傳回值,表示這個執行個體是否等於指定物件。When overridden in a derived class, returns a value that indicates whether this instance equals a specified object.

(繼承來源 Attribute)

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)


_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

將一組名稱對應至一組對應的分派識別項 (Dispatch Identifier)。Maps a set of names to a corresponding set of dispatch identifiers.

(繼承來源 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

擷取物件的類型資訊,可以用來取得介面的類型資訊。Retrieves the type information for an object, which can be used to get the type information for an interface.

(繼承來源 Attribute)

擷取物件提供的類型資訊介面數目 (0 或 1)。Retrieves the number of type information interfaces that an object provides (either 0 or 1).

(繼承來源 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

提供物件所公開的屬性和方法的存取權。Provides access to properties and methods exposed by an object.

(繼承來源 Attribute)