AssemblyKeyFileAttribute Classe
Definizione
Specifica il nome di un file che contiene la coppia di chiavi usata per generare un nome sicuro.Specifies the name of a file containing the key pair used to generate a strong name.
public ref class AssemblyKeyFileAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Assembly, Inherited=false)]
public sealed class AssemblyKeyFileAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Assembly, AllowMultiple=false)]
public sealed class AssemblyKeyFileAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Assembly, Inherited=false)]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class AssemblyKeyFileAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Assembly, Inherited=false)>]
type AssemblyKeyFileAttribute = class
inherit Attribute
[<System.AttributeUsage(System.AttributeTargets.Assembly, AllowMultiple=false)>]
type AssemblyKeyFileAttribute = class
inherit Attribute
[<System.AttributeUsage(System.AttributeTargets.Assembly, Inherited=false)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type AssemblyKeyFileAttribute = class
inherit Attribute
Public NotInheritable Class AssemblyKeyFileAttribute
Inherits Attribute
- Ereditarietà
- Attributi
Esempio
Nell'esempio di codice riportato di seguito viene illustrato l'utilizzo dell' AssemblyDelaySignAttribute attributo con AssemblyKeyFileAttribute .The following code example shows the use of the AssemblyDelaySignAttribute attribute with the AssemblyKeyFileAttribute. Per compilare questo esempio, è necessario creare un file di chiave con nome sicuro denominato TestPublicKey. snk usando il Sn.exe (strumento nome sicuro):To compile this example, you must create a strong-name key file named TestPublicKey.snk using the Sn.exe (Strong Name Tool):
sn -k TestPublicKey.snk
Compilare l'esempio come file con estensione dll.Compile the example as a .dll. Se si compila dalla riga di comando, usare l' /t:library
opzione per C# o Visual Basic oppure l' /LD
opzione del linker per Visual C++.If you compile from the command line, use the /t:library
option for C# or Visual Basic, or the /LD
linker option for Visual C++.
using namespace System;
using namespace System::Reflection;
[assembly:AssemblyKeyFileAttribute("TestPublicKey.snk")];
[assembly:AssemblyDelaySignAttribute(true)];
namespace DelaySign
{
public ref class Test { };
}
using System;
using System.Reflection;
[assembly:AssemblyKeyFileAttribute("TestPublicKey.snk")]
[assembly:AssemblyDelaySignAttribute(true)]
namespace DelaySign
{
public class Test { }
}
Imports System.Reflection
<assembly:AssemblyDelaySignAttribute(true)>
<assembly:AssemblyKeyFileAttribute("TestPublicKey.snk")>
Namespace DelaySign
Public class Test
End Class
End Namespace
Commenti
Quando si compila un assembly con nome sicuro, l'autore deve fornire questo attributo o AssemblyKeyNameAttribute .When building a strong-named assembly, the author must supply either this attribute or AssemblyKeyNameAttribute. Se AssemblyDelaySignAttribute è stato specificato anche, è probabile che il file contenga solo la chiave pubblica.If AssemblyDelaySignAttribute has also been specified, it is likely that this file will only contain the public key.
Un esempio della sintassi è [assembly:AssemblyKeyFileAttribute("myKey.snk")]
.An example of the syntax is [assembly:AssemblyKeyFileAttribute("myKey.snk")]
.
Attenzione
Poiché il percorso e il nome file sono persistenti, verificare che la stringa utilizzata con AssemblyKeyFileAttribute
non contenga informazioni riservate.Since the path and file name persist, ensure that the string you use with AssemblyKeyFileAttribute
does not contain sensitive information.
Costruttori
AssemblyKeyFileAttribute(String) |
Inizializza una nuova istanza della classe |
Proprietà
KeyFile |
Ottiene il nome del file che contiene la coppia di chiavi utilizzata per generare un nome sicuro per l'assembly con attributi.Gets the name of the file containing the key pair used to generate a strong name for the attributed assembly. |
TypeId |
Quando è implementata in una classe derivata, ottiene un identificatore univoco della classe Attribute.When implemented in a derived class, gets a unique identifier for this Attribute. (Ereditato da Attribute) |
Metodi
Equals(Object) |
Restituisce un valore che indica se questa istanza è uguale a un oggetto specificato.Returns a value that indicates whether this instance is equal to a specified object. (Ereditato da Attribute) |
GetHashCode() |
Restituisce il codice hash per l'istanza.Returns the hash code for this instance. (Ereditato da Attribute) |
GetType() |
Ottiene l'oggetto Type dell'istanza corrente.Gets the Type of the current instance. (Ereditato da Object) |
IsDefaultAttribute() |
In caso di override in una classe derivata, indica se il valore di questa istanza è il valore predefinito per la classe derivata.When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Ereditato da Attribute) |
Match(Object) |
Quando è sottoposto a override in una classe derivata, restituisce un valore che indica se questa istanza equivale a un oggetto specificato.When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Ereditato da Attribute) |
MemberwiseClone() |
Crea una copia superficiale dell'oggetto Object corrente.Creates a shallow copy of the current Object. (Ereditato da Object) |
ToString() |
Restituisce una stringa che rappresenta l'oggetto corrente.Returns a string that represents the current object. (Ereditato da Object) |
Implementazioni dell'interfaccia esplicita
_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) |
Esegue il mapping di un set di nomi a un set corrispondente di ID dispatch.Maps a set of names to a corresponding set of dispatch identifiers. (Ereditato da Attribute) |
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) |
Recupera le informazioni sul tipo relative a un oggetto, che possono essere usate per ottenere informazioni sul tipo relative a un'interfaccia.Retrieves the type information for an object, which can be used to get the type information for an interface. (Ereditato da Attribute) |
_Attribute.GetTypeInfoCount(UInt32) |
Recupera il numero delle interfacce di informazioni sul tipo fornite da un oggetto (0 o 1).Retrieves the number of type information interfaces that an object provides (either 0 or 1). (Ereditato da Attribute) |
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) |
Fornisce l'accesso a proprietà e metodi esposti da un oggetto.Provides access to properties and methods exposed by an object. (Ereditato da Attribute) |