15.02.2015 Views

C# 4 and .NET 4

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

C r e a t i n g a s s e m b l i e s ❘ 437<br />

The assembly: prefi x with the attribute marks an assembly - level attribute. Assembly - level attributes are,<br />

in contrast to the other attributes, not attached to a specifi c language element. The arguments that can be<br />

used for the assembly attribute are classes of the namespaces System.Reflection , System.Runtime<br />

.CompilerServices , <strong>and</strong> System.Runtime.InteropServices .<br />

You can read more about attributes <strong>and</strong> how to create <strong>and</strong> use custom attributes in<br />

Chapter 14.<br />

The following table contains a list of assembly attributes defi ned within the System.Reflection<br />

namespace.<br />

a s s e m b ly a T T r i b u T e<br />

d e s C r i P T i o n<br />

AssemblyCompany<br />

Specifi es the company name.<br />

AssemblyConfiguration Specifi es build information such as retail or debugging information.<br />

AssemblyCopyright <strong>and</strong><br />

AssemblyTrademark<br />

Hold the copyright <strong>and</strong> trademark information.<br />

AssemblyDefaultAlias Can be used if the assembly name is not easily readable (such as a GUID when<br />

the assembly name is created dynamically). With this attribute an alias name can<br />

be specifi ed.<br />

AssemblyDescription Describes the assembly or the product. Looking at the properties of the executable<br />

fi le this value shows up as Comments.<br />

AssemblyProduct Specifi es the name of the product where the assembly belongs.<br />

AssemblyTitle Used to give the assembly a friendly name. The friendly name can include<br />

spaces. With the fi le properties you can see this value as Description.<br />

AssemblyCulture Defi nes the culture of the assembly. This attribute is important for satellite<br />

assemblies.<br />

AssemblyInformationalV<br />

ersion<br />

This attribute isn ’ t used for version checking when assemblies are referenced; it<br />

is for information only. It is very useful to specify the version of an application that<br />

uses multiple assemblies. Opening the properties of the executable you can see<br />

this value as the Product Version.<br />

AssemblyVersion This attribute gives the version number of the assembly. Versioning is discussed<br />

later in this chapter.<br />

AssemblyFileVersion This attribute defi nes the version of the fi le. The value shows up with the Windows<br />

fi l e p ro p e r t i e s d i a l o g , b u t i t d o e s n ’ t h ave a ny i n fl u e n ce o n t h e . N E T b e h av i o r.<br />

Here ’ s an example of how these attributes might be confi gured:<br />

[assembly: AssemblyTitle("Professional <strong>C#</strong>")]<br />

[assembly: AssemblyDescription("Sample Application")]<br />

[assembly: AssemblyConfiguration("Retail version")]<br />

[assembly: AssemblyCompany("Wrox Press")]<br />

[assembly: AssemblyProduct("Wrox Professional Series")]<br />

[assembly: AssemblyCopyright("Copyright (C) Wrox Press 2010")]<br />

[assembly: AssemblyTrademark("Wrox is a registered trademark of " +<br />

"John Wiley & Sons, Inc.")]<br />

[assembly: AssemblyCulture("")]<br />

[assembly: AssemblyVersion("1.0.0.0")]<br />

[assembly: AssemblyFileVersion("1.0.0.0")]<br />

www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!