Attributes
Attributes
Attributes Introduction
AttributeUsage STAThread MTAThread Serializable NonSerialized
Attribute Class
All Attributes derive directly or indirectly from System.Attribute. Attributes can be applied to any element indicated by AttributeTargets. Generally Attributes are used as meta-data, as well as, t ey can also be used to c ange t e runtime be aviour of a program.
System.Type
Type is t e first step for all !eflection A"I functions. Can be used wit Classes, Structures, Arrays, Interfaces, "ointers and enumerations. Can be used to create C#$ ob%ects. In C&, typeof operator creates an ob%ect of t is class.
System.Type $embers
IsSubclass#f IsInstance#fType Is'efined IsAssignable(rom IsClass IsCom#b%ect IsAbstract IsArray Invo)e$ember Assembly Assembly*ualified+ame ,aseType $odule +amespace GetType(rom"rogI' GetType(romC-SI'
. at is an Assembly /
An assembly can be either a DLL or EXE. An assembly refers to one or more files that ma e a logical grou!ing
in .NET.
A solution to the DLL "ersioning !roblem. Assemblies are fully self#describing li e the old $%M $om!onents.
'efining $anifest
0ac assembly contains a Manifest and t e compiled code. A manifest is a section in t e assembly w ic contains information li)e
assembly1s version and ot er information particular to an assembly.
-ocating an Assembly
.+0T !untime will locate t e Assembly in following areas3
Application pat "at given by t e application Global Assembly Cac e
Types of Assembly
&lobal Assembly $ache
&A$ is an area for shared common as#semblies. A .NET com!onent can be installed into the &A$ by using the &A$Util.e'e.
(ri)ate Assembly
(ri)ate assembly is an assembly that is only used by a !articular a!!lication. The assembly should reside *ithin the a!!lication directory.
Satellite Assemblies
These are assemblies *hich contain only the resources *ith no e'ecutable code.
7ersioning
A .+0T component can be versioned by using t e sn.e5e s ipped wit .+0T. T e S+.e5e gives a )ey file. T is information s ould be used in t e Assembly8ey(ile attribute. 9ou can ave side-by-side assemblies wit different versions.
AttributeTargets 0numeration
All Assembly Class Constructor 'elegate 0num 0vent (ield Interface $et od $odule "arameter "roperty !eturn7alue
Struct