Applied Microsoft .net framework Programming---Chapter 1

Chapter 1: The Architecture of the .NET Framework Development Platform
1. Compiling Source code into managed modules
    Microsoft is creating several language compilers that target the runtime: C++ with managed extensions, C#, Visual Basic, JScript, and an intermediate language(IL) assembler. In addition to Microsoft, several other compilers are creating compilers that produce code that targets the CLR. You can create source code files using any programming language that supports the CLR, then you use the corresponding compiler to check the syntax and annlyze the source code. Regardless of which compiler you use, the result is a managed module. A managed module is a standard Windows Portable executable(PE) file that requires the CLR to execute.
    The parts of managed module: PE header, CLR header, Metadata, IL code.
    Of all the Microsoft compilers mentioned, C++ is unique in that it is the only language that allows the developer to write both managed and unmanaged code and have it emitted into a single module.

2. Combining Managed Modules into Assemblies
    The CLR doesn't actually work with modules; it works with assemblies. First, an assembly is a logical grouping of one or more managed modules or resource files. Second, an assembly is the smallest unit of reuse, security, and versioning. Depending on the choice you make with your compilers or tools, you can produce a single-file or a multifile assembly.

3. Loading the Common Language Runtime
    Each assembly that you build can be either an executable application or a DLL containing a set of types(components) for use by an executable application. Of course, the CLR is resposible for manage the execution of code contained within these assemblies.
    when you build an EXE assembly, the compiler/linker emits some special information into the resulting assembly's PE file header and the file's .text section. When the EXE file is invoked, this special information cause the CLR to load and initialize. The CLR then locates the application's entry point method and allows the application to start executing. Similarly, if an unmanaged application calls LoadLibrary to load a managed assembly, the DLL's entry point function knows to load the CLR in order to process the code contained within the assembly.
    for more information, turn to page 20 of this book.

4. Executing your Assembly's Code
    Figure 1-4: Calling a method for the first time (Page 24)
    Figure 1-5: Calling a method for the second time (Page 25)

5. IL and Verfication
    IL is stack-based and IL instructions are typeless.
    While compile the IL into CPU native instructions, the CLR performs a process called verification. Verification examines the high-level IL code and ensure that everything it does is "safe".
    The managed module's metadata includes all the method and type information used by the verification process. If the IL code is determined to be "unsafe", then a System.Security.VerificationException exception is thrown.

6. The .NET Framework Class Library (FCL)
7. The Common Type System (CTS)
    The CLR is all about types. Types expose functionality to your application and components. Types are the mechanism by which code written in one programming language can talk to code written in a different programming language.

8. The Common Language Specification
9. Interoperability with Unmanaged Code
    The CLR supports three interoperability scenarios:
      1>. Managed code can call an unmanaged function in a DLL
      2>. Managed code can use an existing COM component(server)
      3>. Unmanaged code can use a managed type(server)

posted on 2006-03-05 17:38  无心三立  阅读(233)  评论(0编辑  收藏  举报

导航