Export (0) Print
Expand All

AssemblyTitleAttribute Class

Specifies a description for an assembly.

System.Object
  System.Attribute
    System.Reflection.AssemblyTitleAttribute

Namespace:  System.Reflection
Assembly:  mscorlib (in mscorlib.dll)

[ComVisibleAttribute(true)]
[AttributeUsageAttribute(AttributeTargets.Assembly, Inherited = false)]
public sealed class AssemblyTitleAttribute : Attribute

The AssemblyTitleAttribute type exposes the following members.

  NameDescription
Public methodSupported by the XNA FrameworkSupported by Portable Class LibrarySupported in .NET for Windows Store appsAssemblyTitleAttributeInitializes a new instance of the AssemblyTitleAttribute class.
Top

  NameDescription
Public propertySupported by the XNA FrameworkSupported by Portable Class LibrarySupported in .NET for Windows Store appsTitleGets assembly title information.
Public propertyTypeIdWhen implemented in a derived class, gets a unique identifier for this Attribute. (Inherited from Attribute.)
Top

  NameDescription
Public methodSupported by the XNA FrameworkSupported by Portable Class LibrarySupported in .NET for Windows Store appsEqualsInfrastructure. Returns a value that indicates whether this instance is equal to a specified object. (Inherited from Attribute.)
Public methodSupported by the XNA FrameworkSupported by Portable Class LibrarySupported in .NET for Windows Store appsGetHashCodeReturns the hash code for this instance. (Inherited from Attribute.)
Public methodSupported by the XNA FrameworkSupported by Portable Class LibrarySupported in .NET for Windows Store appsGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodIsDefaultAttributeWhen overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Inherited from Attribute.)
Public methodSupported by the XNA FrameworkMatchWhen overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from Attribute.)
Public methodSupported by the XNA FrameworkSupported by Portable Class LibrarySupported in .NET for Windows Store appsToStringReturns a string that represents the current object. (Inherited from Object.)
Top

  NameDescription
Explicit interface implemetationPrivate method_Attribute.GetIDsOfNamesMaps a set of names to a corresponding set of dispatch identifiers. (Inherited from Attribute.)
Explicit interface implemetationPrivate method_Attribute.GetTypeInfoRetrieves the type information for an object, which can be used to get the type information for an interface. (Inherited from Attribute.)
Explicit interface implemetationPrivate method_Attribute.GetTypeInfoCountRetrieves the number of type information interfaces that an object provides (either 0 or 1). (Inherited from Attribute.)
Explicit interface implemetationPrivate method_Attribute.InvokeProvides access to properties and methods exposed by an object. (Inherited from Attribute.)
Top

The assembly title is a friendly name, which can include spaces.

In Windows Vista, the information specified for this attribute appears on the Details tab of the Windows File Properties dialog box for the assembly. The property name is File description. In Windows XP, this information appears on the Version tab of the Windows File Properties dialog box.

The following example shows how to add attributes, including the AssemblyTitleAttribute attribute, to a dynamic assembly. The example saves the assembly to disk, and the attribute value can be viewed by using the Windows File Properties dialog box.

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");

   }
}

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

.NET for Windows Store apps

Supported in: Windows 8

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone Silverlight 8.1, Windows Phone Silverlight 8

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft