AssemblyCompanyAttribute Klas
Definitie
Belangrijk
Bepaalde informatie heeft betrekking op een voorlopige productversie die aanzienlijk kan worden gewijzigd voordat deze wordt uitgebracht. Microsoft biedt geen enkele expliciete of impliciete garanties met betrekking tot de informatie die hier wordt verstrekt.
Hiermee definieert u een aangepast kenmerk voor een bedrijfsnaam voor een assemblymanifest.
public ref class AssemblyCompanyAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Assembly, Inherited=false)]
public sealed class AssemblyCompanyAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Assembly, AllowMultiple=false)]
public sealed class AssemblyCompanyAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Assembly, Inherited=false)]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class AssemblyCompanyAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Assembly, Inherited=false)>]
type AssemblyCompanyAttribute = class
inherit Attribute
[<System.AttributeUsage(System.AttributeTargets.Assembly, AllowMultiple=false)>]
type AssemblyCompanyAttribute = class
inherit Attribute
[<System.AttributeUsage(System.AttributeTargets.Assembly, Inherited=false)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type AssemblyCompanyAttribute = class
inherit Attribute
Public NotInheritable Class AssemblyCompanyAttribute
Inherits Attribute
- Overname
- Kenmerken
Voorbeelden
In het volgende voorbeeld ziet u hoe u kenmerken, inclusief het AssemblyCompanyAttribute kenmerk, toepast op een dynamische assembly. In het voorbeeld wordt de assembly op schijf opgeslagen en de kenmerkwaarde kan worden weergegeven met behulp van het dialoogvenster Windows Bestandseigenschappen.
using System;
using System.Reflection;
using System.Reflection.Emit;
class Example
{
public static void Main()
{
AssemblyName assemName = new AssemblyName();
assemName.Name = "EmittedAssembly";
// Create a dynamic assembly in the current application domain,
// specifying that the assembly is to be saved.
//
AssemblyBuilder myAssembly =
AppDomain.CurrentDomain.DefineDynamicAssembly(assemName,
AssemblyBuilderAccess.Save);
// To apply an attribute to a dynamic assembly, first get the
// attribute type. The AssemblyFileVersionAttribute sets the
// File Version field on the Version tab of the Windows file
// properties dialog.
//
Type attributeType = typeof(AssemblyFileVersionAttribute);
// To identify the constructor, use an array of types representing
// the constructor's parameter types. This ctor takes a string.
//
Type[] ctorParameters = { typeof(string) };
// Get the constructor for the attribute.
//
ConstructorInfo ctor = attributeType.GetConstructor(ctorParameters);
// Pass the constructor and an array of arguments (in this case,
// an array containing a single string) to the
// CustomAttributeBuilder constructor.
//
object[] ctorArgs = { "2.0.3033.0" };
CustomAttributeBuilder attribute =
new CustomAttributeBuilder(ctor, ctorArgs);
// Finally, apply the attribute to the assembly.
//
myAssembly.SetCustomAttribute(attribute);
// The pattern described above is used to create and apply
// several more attributes. As it happens, all these attributes
// have a constructor that takes a string, so the same ctorArgs
// variable works for all of them.
// The AssemblyTitleAttribute sets the Description field on
// the General tab and the Version tab of the Windows file
// properties dialog.
//
attributeType = typeof(AssemblyTitleAttribute);
ctor = attributeType.GetConstructor(ctorParameters);
ctorArgs = new object[] { "The Application Title" };
attribute = new CustomAttributeBuilder(ctor, ctorArgs);
myAssembly.SetCustomAttribute(attribute);
// The AssemblyCopyrightAttribute sets the Copyright field on
// the Version tab.
//
attributeType = typeof(AssemblyCopyrightAttribute);
ctor = attributeType.GetConstructor(ctorParameters);
ctorArgs = new object[] { "© My Example Company 1991-2005" };
attribute = new CustomAttributeBuilder(ctor, ctorArgs);
myAssembly.SetCustomAttribute(attribute);
// The AssemblyDescriptionAttribute sets the Comment item.
//
attributeType = typeof(AssemblyDescriptionAttribute);
ctor = attributeType.GetConstructor(ctorParameters);
attribute = new CustomAttributeBuilder(ctor,
new object[] { "This is a comment." });
myAssembly.SetCustomAttribute(attribute);
// The AssemblyCompanyAttribute sets the Company item.
//
attributeType = typeof(AssemblyCompanyAttribute);
ctor = attributeType.GetConstructor(ctorParameters);
attribute = new CustomAttributeBuilder(ctor,
new object[] { "My Example Company" });
myAssembly.SetCustomAttribute(attribute);
// The AssemblyProductAttribute sets the Product Name item.
//
attributeType = typeof(AssemblyProductAttribute);
ctor = attributeType.GetConstructor(ctorParameters);
attribute = new CustomAttributeBuilder(ctor,
new object[] { "My Product Name" });
myAssembly.SetCustomAttribute(attribute);
// Define the assembly's only module. For a single-file assembly,
// the module name is the assembly name.
//
ModuleBuilder myModule =
myAssembly.DefineDynamicModule(assemName.Name,
assemName.Name + ".exe");
// No types or methods are created for this example.
// Define the unmanaged version information resource, which
// contains the attribute informaion applied earlier, and save
// the assembly. Use the Windows Explorer to examine the properties
// of the .exe file.
//
myAssembly.DefineVersionInfoResource();
myAssembly.Save(assemName.Name + ".exe");
}
}
Imports System.Reflection
Imports System.Reflection.Emit
Module Example
Sub Main()
Dim assemName As New AssemblyName()
assemName.Name = "EmittedAssembly"
' Create a dynamic assembly in the current application domain,
' specifying that the assembly is to be saved.
'
Dim myAssembly As AssemblyBuilder = _
AppDomain.CurrentDomain.DefineDynamicAssembly(assemName, _
AssemblyBuilderAccess.Save)
' To apply an attribute to a dynamic assembly, first get the
' attribute type. The AssemblyFileVersionAttribute sets the
' File Version field on the Version tab of the Windows file
' properties dialog.
'
Dim attributeType As Type = GetType(AssemblyFileVersionAttribute)
' To identify the constructor, use an array of types representing
' the constructor's parameter types. This ctor takes a string.
'
Dim ctorParameters() As Type = { GetType(String) }
' Get the constructor for the attribute.
'
Dim ctor As ConstructorInfo = _
attributeType.GetConstructor(ctorParameters)
' Pass the constructor and an array of arguments (in this case,
' an array containing a single string) to the
' CustomAttributeBuilder constructor.
'
Dim ctorArgs() As Object = { "2.0.3033.0" }
Dim attribute As New CustomAttributeBuilder(ctor, ctorArgs)
' Finally, apply the attribute to the assembly.
'
myAssembly.SetCustomAttribute(attribute)
' The pattern described above is used to create and apply
' several more attributes. As it happens, all these attributes
' have a constructor that takes a string, so the same ctorArgs
' variable works for all of them.
' The AssemblyTitleAttribute sets the Description field on
' the General tab and the Version tab of the Windows file
' properties dialog.
'
attributeType = GetType(AssemblyTitleAttribute)
ctor = attributeType.GetConstructor(ctorParameters)
ctorArgs = New Object() { "The Application Title" }
attribute = New CustomAttributeBuilder(ctor, ctorArgs)
myAssembly.SetCustomAttribute(attribute)
' The AssemblyCopyrightAttribute sets the Copyright field on
' the Version tab.
'
attributeType = GetType(AssemblyCopyrightAttribute)
ctor = attributeType.GetConstructor(ctorParameters)
ctorArgs = New Object() { "© My Example Company 1991-2005" }
attribute = New CustomAttributeBuilder(ctor, ctorArgs)
myAssembly.SetCustomAttribute(attribute)
' The AssemblyDescriptionAttribute sets the Comment item.
'
attributeType = GetType(AssemblyDescriptionAttribute)
ctor = attributeType.GetConstructor(ctorParameters)
attribute = New CustomAttributeBuilder(ctor, _
New Object() { "This is a comment." })
myAssembly.SetCustomAttribute(attribute)
' The AssemblyCompanyAttribute sets the Company item.
'
attributeType = GetType(AssemblyCompanyAttribute)
ctor = attributeType.GetConstructor(ctorParameters)
attribute = New CustomAttributeBuilder(ctor, _
New Object() { "My Example Company" })
myAssembly.SetCustomAttribute(attribute)
' The AssemblyProductAttribute sets the Product Name item.
'
attributeType = GetType(AssemblyProductAttribute)
ctor = attributeType.GetConstructor(ctorParameters)
attribute = New CustomAttributeBuilder(ctor, _
New Object() { "My Product Name" })
myAssembly.SetCustomAttribute(attribute)
' Define the assembly's only module. For a single-file assembly,
' the module name is the assembly name.
'
Dim myModule As ModuleBuilder = _
myAssembly.DefineDynamicModule(assemName.Name, _
assemName.Name & ".exe")
' No types or methods are created for this example.
' Define the unmanaged version information resource, which
' contains the attribute informaion applied earlier, and save
' the assembly. Use the Windows Explorer to examine the properties
' of the .exe file.
'
myAssembly.DefineVersionInfoResource()
myAssembly.Save(assemName.Name & ".exe")
End Sub
End Module
Constructors
| Name | Description |
|---|---|
| AssemblyCompanyAttribute(String) |
Initialiseert een nieuw exemplaar van de AssemblyCompanyAttribute klasse. |
Eigenschappen
| Name | Description |
|---|---|
| Company |
Hiermee haalt u bedrijfsnaamgegevens op. |
| TypeId |
Wanneer deze wordt geïmplementeerd in een afgeleide klasse, krijgt u Attributehiervoor een unieke id. (Overgenomen van Attribute) |
Methoden
| Name | Description |
|---|---|
| Equals(Object) |
Retourneert een waarde die aangeeft of dit exemplaar gelijk is aan een opgegeven object. (Overgenomen van Attribute) |
| GetHashCode() |
Retourneert de hash-code voor dit exemplaar. (Overgenomen van Attribute) |
| GetType() |
Hiermee haalt u de Type huidige instantie op. (Overgenomen van Object) |
| IsDefaultAttribute() |
Wanneer deze wordt overschreven in een afgeleide klasse, geeft u aan of de waarde van dit exemplaar de standaardwaarde is voor de afgeleide klasse. (Overgenomen van Attribute) |
| Match(Object) |
Wanneer deze wordt overschreven in een afgeleide klasse, wordt een waarde geretourneerd die aangeeft of dit exemplaar gelijk is aan een opgegeven object. (Overgenomen van Attribute) |
| MemberwiseClone() |
Hiermee maakt u een ondiepe kopie van de huidige Object. (Overgenomen van Object) |
| ToString() |
Retourneert een tekenreeks die het huidige object vertegenwoordigt. (Overgenomen van Object) |
Expliciete interface-implementaties
| Name | Description |
|---|---|
| _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) |
Hiermee wordt een set namen toegewezen aan een bijbehorende set verzend-id's. (Overgenomen van Attribute) |
| _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) |
Hiermee haalt u de typegegevens voor een object op, die kan worden gebruikt om de typegegevens voor een interface op te halen. (Overgenomen van Attribute) |
| _Attribute.GetTypeInfoCount(UInt32) |
Hiermee wordt het aantal type-informatieinterfaces opgehaald dat een object biedt (0 of 1). (Overgenomen van Attribute) |
| _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) |
Biedt toegang tot eigenschappen en methoden die door een object worden weergegeven. (Overgenomen van Attribute) |