Applied .Net Framework

1. Several concepts:
Managed Module: the compiled result of a code file, one file one module. The file extension is .netmodule
Assembly: a logic collection of managed module with one central module has special metadata(manifest), so we can create multifile(multimodule) assembly.
Metadata: included in every managed module, a set of data tables describes what is defined in this module. Including type/member define and type/member ref.
Manifest: included in every assembly, another set of metadata tables describes the files make up the assembly and the publicly exported types, and the resource or data.

2. Metadata Advantage
#1. Omit the need of lib and .h files
#2, Providing intellisense
#3, For CLR verification
#4, Providing the type information for remote serialization
#5, Providing the information GC needed to track the referenced objects etc.

3. Assembly Probing
<configuration>
   <runtime>
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
         < probing privatePath="bin;bin2\subbin;bin3"/>
      </assemblyBinding>
   </runtime>
</configuration>
All the path in the privatePath should relative to the application base directory, we can not specify a dir relative or absolut path out of the application base directory.

#1, Culture-neutral assembly
Application base\AsemName.dll
Application base\AsemName\AsemName.dll
Application base\privatePath1\AsemName.dll
Application base\privatePath1\AsemName\AsemName.dll
Application base\privatePath2\AsemName.dll
Application base\privatePath2\AsemName\AsemName.dll

#2, Satellite assembly
Application base\en-US\AsemName.dll
Application base\en-US\AsemName\AsemName.dll
Application base\en-US\privatePath1\AsemName.dll
Application base\en-US\privatePath1\AsemName\AsemName.dll
Application base\en-US\privatePath2\AsemName.dll
Application base\en-US\privatePath2\AsemName\AsemName.dll

4. In manifest, only the referenced assembly's Public key token was stored as AssemblyRef table. while AssemblyDef entry stores the full public key, not public key token.

5. C# allows implicit cast if conversion is safe, that is, no loss of data is possible.(If the data will lost, we have to explicitly cast)
We may use Convert.ChangeType static method to convert different types, once they implemented IConvertible interface.

6. CLR performs arithmetic operation on 32-bit and 64-bit values only. 
7. The type overflow checking is turned off, we may use "checked" keyword to turn it on, (Note: "checked" does not check into the method that it is wrapped.) This will cause System.OverflowException to be thrown.
8. Decimal types will have no arithmetic operation IL code, so it makes no means for "checked". It will always throw OverflowException.
9. Value types are allocated from thread stack. Once the Type(class) definer, not the user can control the allocation place.
10. C# will ensure all the value types to be zero, but C# "think" the instance initialized with "new" keyword.

你可能感兴趣的:(framework)