Você está na página 1de 5

.net binaries A .NET PE is a PE just like the others.

It has an MZ header, a DOS segment, a PE header, a section table and sections: .text, .reloc, .rsrc. So far, everything is normal. A "typical" Windows binary contains all of these things, only the sections vary , depending on the compiler and language. The .text table contains an import table that imports one single DLL, mscoree.dll, and one single function, _CorExeMain. It also contains the .NET section: data about how your program works (classes, methods, etc), metadata and IL. So what happens when you start a .NET binary? Nothing really fancy. It simply works just like a "typical" Windows binary. It calls upon mscoree.dll to create a .NET runtime, that will load the .NET section of your executable. That runtime knows how to execute IL.

Metadata Metadata is binary information describing your program that is stored either in a common language runtime portable executable (PE) file or in memory. When you compile your code into a PE file, metadata is inserted into one portion of the file, while your code is converted to Microsoft intermediate language (MSIL) and inserted into another portion of the file. Every type and member defined and referenced in a module or assembly is described within metadata. When code is executed, the runtime loads metadata into memory and references it to discover information about your code's classes, members, inheritance, and so on. Metadata describes every type and member defined in your code in a language-neutral manner. 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.

Benefits of Metadata Metadata is the key to a simpler programming model, eliminating the need for Interface Definition Language (IDL) files, header files, or any external method of component reference. Metadata allows .NET languages to describe themselves automatically in a language-neutral manner, unseen by both the developer and the user. Additionally, metadata is extensible through the use of attributes. Metadata provides the following major benefits:

Self-describing files. Common language runtime modules and assemblies are self-describing. A module's metadata contains everything needed to interact with another module. Metadata automatically provides the functionality of IDL in COM, allowing you to use one file for both definition and implementation. Runtime modules and assemblies do not even require registration with the operating system. As a result, the descriptions used by the runtime always reflect the actual code in your compiled file, which increases application reliability.

Language interoperability and easier component-based design. Metadata provides all the information required about compiled code for you to inherit a class from a PE file written in a different language. You can create an instance of any class written in any managed language (any language that targets the common language runtime) without worrying about explicit marshaling or using custom interoperability code.

Attributes. The .NET Framework allows you to declare specific kinds of metadata, called attributes, in your compiled file. Attributes can be found throughout the .NET Framework and are used to control in more detail how your program behaves at run time. Additionally, you can emit your own custom metadata into .NET Framework files through user-defined custom attributes.

.net types and .net name spaces isual Basic type Boolean Byte Char Date Common language runtime type structure Nominal storage allocation 2 bytes 1 byte 2 bytes 8 bytes Value range

System.Boolean System.Byte System.Char System.DateTime

True or False. 0 through 255 (unsigned). 0 through 65535 (unsigned). 0:00:00 on January 1, 0001 through 11:59:59 PM on December 31, 9999.

Decimal

System.Decimal

16 bytes

0 through +/79,228,162,514,264,337,593,543,950,335 with no decimal point; 0 through +/7.9228162514264337593543950335 with 28 places to the right of the decimal; smallest nonzero number is +/-0.0000000000000000000000000001 (+/-1E-28). -1.79769313486231570E+308 through -4.94065645841246544E-324 for negative values; 4.94065645841246544E-324 through 1.79769313486231570E+308 for positive values. -2,147,483,648 through 2,147,483,647. -9,223,372,036,854,775,808 through 9,223,372,036,854,775,807.

Double (doubleprecision floatingpoint)

System.Double

8 bytes

Integer Long (long integer) Object

System.Int32 System.Int64

4 bytes 8 bytes

System.Object (class)

4 bytes

Any type can be stored in a variable of type Object. -32,768 through 32,767. -3.4028235E+38 through -1.401298E-45 for negative values; 1.401298E-45 through 3.4028235E+38 for positive values.

Short Single (singleprecision floatingpoint) String (variablelength)

System.Int16 System.Single

2 bytes 4 bytes

System.String (class)

Depends on implementing platform

0 to approximately 2 billion Unicode characters.

UserDefined Type (structure)

(inherits from System.ValueType)

Depends on implementing platform

Each member of the structure has a range determined by its data type and independent of the ranges of the other members.

System System.CodeDom.Compiler System.Collections System.Collections.Generic System.Collections.ObjectModel System.Collections.Specialized System.ComponentModel System.Configuration.Assemblies System.Diagnostics System.Diagnostics.CodeAnalysis System.Globalization System.IO System.Net System.Reflection System.Resources System.Runtime.CompilerServices System.Runtime.InteropServices System.Runtime.Serialization System.Security System.Security.Permissions System.Security.Policy System.Text System.Text.RegularExpressions System.Threading System.Xml System.Xml.Schema System.Xml.Serialization System.Xml.XPath System.Xml.Xsl

Common Language Specification A set of base rules to which any language targeting the CLI should conform in order to interoperate with other CLS-compliant languages. The CLS rules define a subset of the Common Type System. Definition - What does Common Language Specification (CLS) mean? The Common Language Specification (CLS) is a fundamental set of language features supported by the Common Language Runtime (CLR) of the .NET Framework. CLS is a part of the specifications of the .NET Framework. CLS was designed to support language constructs commonly used by developers and to produce verifiable code, which allows all CLS-compliant languages to ensure the type safety of code. CLS includes features common to many object-oriented programming languages. It forms a subset of the functionality of common type system (CTS) and has more rules than defined in CTS.

Você também pode gostar