Chapter 2
1. The CLR program is exemplified in the module. A CLR module is a byte stream that is stored in a file (local or remote server).
2. The CLR module uses the WinNT's PE (Portable Executable) extension in the format format. The CLR module is also a valid Win32 module that can be loaded through the LoadLibrary system call. The PE / COFF used by the CLR module is very small, and most of the content is part of the PE / COFF file.
3. The CLR module includes code, metadata, and resources. Code is stored in a CIL (Common Intermediate Language) format (personal understanding: this and MSIL or IL is a thing). The metadata of the module describes the type defined in the module, contains name, inheritance, method signing, and dependencies. The resource of the module is composed of static read-only data (string, bitmap, etc.).
4. (/ T: EXE, / T: WINEXE, / T: LIBRARY, / T: MODULE) Module generates "unprocessed" module (.NETMODULE). / T: The module (.dll) generated by library is included in the module (.dll) contains metadata. / T: EXE generates a console program, / T: WinExe generates WIN programs.
5. The starting point is one of the four forms: static void main () {}, static void main (string [] argv) {}, static void main () {return 0}, static void main (string [] argv) { RETURN 0}. Is there a public that does not matter, a program does not have multiple portals, multiple main functions need to use the / main switch when compiling.
6. Assembly (Assembly) is a logical collection of one or more modules. The assembly is incorporated by reference independently. This name must be translated into a file system or a physical path on the Internet, eventually pointing to one or more modules that contain type definitions, code, and resources.
7. The role of "Multi-Module" is to separate the "common" and "uncommon" code loaded (can be "what to download when running"), you can use a language to write the underlying, one Language write interface.
8. A module often only belongs to an assembly. If you need to violate, then this common module will be generated two unused copies.
9. The module depends on the type from other assemblies (at least Mscorlib.dll), each module has a list of online names, and then the CLR is responsible for converting the names of these assemblies into module path names at runtime. .
10. Each assembly has an assembly list (Assembly Manifest), which is part of the metadata, which is equivalent to the attached type definition and the subject of the code.
11. The module containing the assembly list is first loaded by the CLR, and then load the remaining no list of modules according to the content of this list.
12. Reference other modules use the / addModule switch, reference other assemblies to use the / R switch.
13. The module containing the assembly list will contain the main list of external reference assemblies. The list consists of the dependency of each module in the program set, which can find all the dependencies of the assembly by loading a file.
14. INTERNAL leads to only the modules that are only available to the same assembly, causing all code available; private can only be used by this type; protected makes the method of derived classes can also access the member; Protected and INternal can be used together. 15. Namespace class name.
16. Each assembly uses a four-part name as a unique identifier. These four parts are names, culture, developers, and component versions. These names are placed in the list of assembly, when loading, the CLR uses the four assembly name to find the correct component.
17. The name of each assembly has a version number: Major.minor.Build.Revision, if there is no explicit setting number, then
0.0.0
.0. System.Reflection.Assemblyversion can accept a variety of string formats (1.2.d.s, etc.).
18. The CultureInfo feature identifies the language and country code used in component development (language environment). The assembly containing the CultureInfo feature cannot include code, must be a "resource-only) of" Pure Resources ". The assembly containing the code is a cultural unrelated (Culture-neutral).
19. The assembly name contains a "public key" that identifies the developer of the component. You can choose to use 8-bit or 128-bit public key marks so that different assemblies of the same file name can be marked.
20. Sometimes you must manually reference the assembly. The CLR defines a standard format to write strings from the four parts of the assembly. This format is called the display name of the assembly: name, virsion = x.x.x.x, culture = [xx-xx | neutral], publickeyToken = [xxxxxxxxxxxx | null]. Culture indicates that there is no cultural restriction in the assembly for Neutral, and publickeyToken indicates no public key. Simply omitted a part of the qualified name indicates that any Culture or PublickeyToken is allowed.
21. In general, some partial qualifications of the assembly should be avoided, otherwise the CLR may operate in a non-expected manner. You can write a full name in the configuration file and then use the partial name to call in the program (askSEMBLY ASSM = Assembly.Load ("xxxx")). PartialName (above XXXX) must exist in PartialName of the configuration file
22. The CLR will try to load unwanted modules as much as possible, and will be loaded when it is indeed used. This reduces the initialization time and also reduces the resources consumed by the running program. The CLR load is triggered by a type-based JIT compiler. When JIT compiles the CIL of the method into a machine code, the local variables, parameters, etc., parameters, and the like are loaded together.
23. If you don't have a Cl R, you can have two practices: First, define some static fields. Second, use manual explicit loading.
24. If you want to explicitly interact, you need to use System.Reflection.Assembly's LoadFrom method, which can be a local file, or "file: // ...", if it is "File : // ... "The URL is called, then Web Permission is required, which is first downloaded to the cache when loading it.
25. Although it is very interesting through the location loading assembly, most of the assemblies are loaded by the program set parser (Assembly Resolver). The method is the LOAD method of System.Reflection.Assembly, involves the problem of the directory, version control, and some other configuration details. 26. The assembly parser first uses a valid version policy (Version Policy), and then the replacement version of the desired assembly may be loaded (different versions of the assembly for different assemblies, but the program set must be the same name) . The version policy can only be applied to the fully qualified assembly of four parts, if the program set name is partially qualified (such as missing public key mark, version or culture), then the version strategy is not available (directly using the loadFrom method due to the specified File, so there is no problem with any version strategy).
27. The version policy can be determined by the configuration file, the computer range (Machine-Wide) configuration file is Machine.config, which is stored in the% systemroot% / microsoft.net / framework / v1.0.nnn / config directory. For application-wide configuration files, ordinary applications are in the application directory, and the file name is a config extension after the file name is named. ASP.NET is web.config.
28. The configuration file is an XML language file, there is always a root element of Configuration. The settings of these profiles control the probe path and the issuer version policy mode. In addition, the DependentAssembly element is used to set versions and location settings for each dependent assembly. (Profiles have an example in the Chinese version P36).
29. Version Policy Specified at three levels: Per Apponent à Components (Per Machine). The former output is the input of the latter.
30. In addition to the specific applications and computer-wide configuration files, the given assembly also has a Publisher Policy. It is declared by a developer that indicates which versions are compatible with each other.
31. Chinese Page P39 - Display the entire process of finding the assembly parser for the assembly parser.
32. In order to avoid unity, the assembly parser only looks for GAC when the public key is included in the requested assembly name. The public key can be explicitly provided as part of the assembly reference or the Assembly.Load parameter, or can be implicitly provided via the QualityAssembly configuration file.
33. The GAC is controlled by the system-level component (Fusion.dll), and the DLL cache is stored in the% WinNT% / Assembly directory.
34. CodeBase prompt configuration file instance: Chinese version P41 Page
35. If the assembly parser cannot locate the assembly via the GAC or CodeBase prompt, the program set parser will find the directory related to the application root directory. This look is called probing. (Chinese book P43 - P45 page)
36. The assembly is versioned into a unit. If a subset of files in the assembly is replaced, not updating the version number, will result in unpredictable results. If the type of functional agreement changes, the type of assembly must give a new version number.
37. CodeBase prompts, private probe paths, and GACs can support multiple versions of parallel installations, which allow multiple versions of the given assembly to peacefully coexist in the file system. However, if there are multiple such an assembly being loaded into memory by a standalone or a single program, then things are unpredictable to some extent. Parallel implementation is more difficult to handle more than parallel installations. 38. The shared type needs to be deployed to a separate assembly, which itself will not be versioned. (Compared with "Applied", it is similar to the interface application.
39. The original data used for the assembly has three special features that allow the developer to develop the version of the assembly to be loaded at the same time. These metadata is ignored by the current assembly parser and the loader. However, they can actually be prompted, this prompt is expected to be implemented in the future version of the CLR.