1 / 11

.NET Framework Introduction: Metadata

.NET Framework Introduction: Metadata. Ketan Bibave. Overview . What is Metadata? How is Metadata? Structure of Metadata Tables Functions or benefits of Metadata. What is Metadata?.

jean
Download Presentation

.NET Framework Introduction: Metadata

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. .NET Framework Introduction:Metadata KetanBibave

  2. Overview • What is Metadata? • How is Metadata? • Structure of Metadata Tables • Functions or benefits of Metadata

  3. What is Metadata? • The .NET Framework makes component interoperation even easier by allowing compilers to emit additional declarative information into all modules and assemblies. This information, called metadata, helps components to interact seamlessly. • It also known as “self-contained” type library. • Metadata is binary information describing your program that is stored in Managed module. • Every type and member that is defined and referenced in a module or assembly is described within metadata. 

  4. How is Metadata? • Metadata stores the following information: • Description of the assembly. • Identity (name, version, culture, public key). • The types that are exported. • Other assemblies that this assembly depends on. • Security permissions needed to run. • Description of types. • Name, visibility, base class, and interfaces implemented. • Members (methods, fields, properties, events, nested types). • Attributes. • Additional descriptive elements that modify types and members. • All Metadata in the form of tables and all table internally in the forms of hexadecimal numbers. • Metadata is of two type • DefType (Defined) • RefType (Referenced) • There are only 15 tables divided into above two types of tables.

  5. How is Metadata? • Metadata Token • A metadata token is a four-byte number. • The top byte denotes the metadata table to which a particular token refers (method, type, and so on). The remaining three bytes specify the row in the metadata table that corresponds to the programming element being described. • If we define a method in C# and compile it into a PE file, the following metadata token might exist in the MSIL portion of the PE file • 0x06000004 • The top byte (0x06) indicates that this is a MethodDef token. The lower three bytes (000004) tells the common language runtime to look in the fourth row of the MethodDef table for the information that describes this method definition • Metadata also stores information in four heap structures: • string, blob, user string, and GUID. • All the strings used to name types and members are stored in the string heap. • For example, a method table does not directly store the name of a particular method, but points to the method's name stored in the string heap.

  6. Structure of Metadata Tables

  7. Structure of Metadata Tables: 11 Defined Type Table

  8. Structure of Metadata Tables: 4 Reference Type Table

  9. Functions or benefits of Metadata • Metadata allows CLR to do Type Safe Verification and hence metadata makes AppDomain possible. • CLR uses metadata for following operations • For object lifetime maintenance and therefore metadata is responsible to automatic garbage collection. • For serialization, deserialization, marshalling and Remote method Invocation using Network data transfer • CLR does Introspection and Reflection. • IDE uses metadata for intellisense feature. • Metadata eliminates the need for Interface Definition Language (IDL) files, header files, or any external method of component reference. • Metadata enables .NET Framework languages to describe themselves automatically in a language-neutral manner

  10. Functions or benefits of Metadata • Self-describing files • Common language runtime modules and assemblies are self-describing. • Metadata automatically provides the functionality of IDL in COM, so we can use one file for both definition and implementation. • Language interoperability and easier component-based design. • We can create an instance of any class written in any managed language without worrying about explicit marshalling or using custom interoperability code. • Attributes • Attributes are used to control in more detail how your program behaves at run time. • We can emit our own custom metadata into .NET Framework files through user-defined custom attributes.

  11. External References • Gokhale Sir Notes. • Metadata and Self-Describing Components • Metadata and the PE File Structure • Run-Time Use of Metadata

More Related