Applied Microsoft .net framework Programming---Chapter 1

本文详细介绍了.NET Framework开发平台的架构,包括源代码编译为托管模块的过程、托管模块的组成部分、组合托管模块形成组件的方法、公共语言运行时的加载方式、中间语言及其验证过程、.NET Framework类库的作用、通用类型系统的功能、与非托管代码互操作的三种情景等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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)

转载于:https://www.cnblogs.com/dotrai/archive/2006/03/05/343372.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值