Mais conteúdo relacionado
Semelhante a CLRの基礎 - プログラミング .NET Framework 第3版 読書会 (20)
Mais de Yoshihisa Ozaki (13)
CLRの基礎 - プログラミング .NET Framework 第3版 読書会
- 2. 尾崎 義尚 Ozaki Yoshihisa
• Twitter:@yoshioms
• http://d.hatena.ne.jp/yoshioms/
• 詳細プロファイル:http://bit.ly/yoshioms
• 3月末で会社を退社。現在、無職
• 家族構成:
– 僕:無職
– 妻:専業主婦
– 猫A
– 猫B(C)
- 8. 参加者のタイプを想定
CLR
GC
FCL タイプシステム
Dynamic
Serialize
Threading
アーキテクチャ
業務
開発プロセス
ハードウェア
フレームワーク コーディング
序文
- 11. 序文候補者ランキング
1 Bill Gates アメリカ合衆国の実業家
2 Steve Ballmer アメリカ合衆国の実業家
3 Catherine Zeta-Jones イギリスの女優
・・・
14 Kristin Trace 主婦
- 12. Catherine Zeta-Jones
• 誕生日:1969年9月25日 (41歳)
• 国籍:イギリス
• 職業:女優
• 配偶者:Michael Douglas
• 主な作品:
– マスク・オブ・ゾロ
– トラフィック
– シカゴ 接点
- 17. コンパイル
ソースファイル コンパイラ アセンブリ
CSC
VBC 中間言語 (IL:
Intermediate
Language)
- 18. アセンブリの構造
• Windows PE(Portable Executable)
– PEとは、要はCOFF(Common Object File Format)
• Unixなどでも使われているオブジェクト ファイル フォー
マット
実行ファイル
MS-DOS 未 OEM MS-DOS 2.0 未 PEヘッダ セクションヘッダ インポート ページ
2.0 互換 使 情報 スタブ & 使 Import Information
ヘッダ 用 リロケーション 用 Export Information ・・・
テーブル Base relocations
Resource Information
MS-DOS Stub PE Signature COFF File Header Option Header
“This program cannot Machine Magic
“PE”¥0¥0
be run in DOS mode” MajorLinkerVersion
NumberOfSections
MinorLinkerVersion
TimeDateStamp SizeOfCode
SizeOfInitializedData
PointerToSymbolTable SizeOfUninitializedData
AddressOfEntryPoint
NumberOfSymbols BaseOfCode
SizeOfOptionalHeader
Characteristics
- 20. プラットフォーム指定による動作(/platform)
/platform x86 Windows x64 Windows IA64 Windows
なし 32ビット 64ビット 64ビット
anycpu
x86 32ビット WoW64 WoW64
x64 動作しない 64ビット 動作しない
Itanium 動作しない 動作しない 64ビット
通常は指定なし(anycpu)でよい
- 25. アセンブリの中身 – マニフェスト
// Metadata version: v4.0.30319
.assembly extern mscorlib アセンブリ
{ メタデータ
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z¥V.4..
.ver 4:0:0:0
}
.assembly a
{
型メタデータ
.custom instance void
[mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ct
or(int32) = ( 01 00 08 00 00 00 00 00 )
.custom instance void
[mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.cto
r() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx
63 65 70 74 69 6F 6E
54 68 72 6F 77 73 01 ) // ceptionThrows.
.hash algorithm 0x00008004
.ver 0:0:0:0
}
.module a.exe
// MVID: {65EF1A30-A0C7-42B6-8BC9-EA8332F6DEFC}
.imagebase 0x00400000
.file alignment 0x00000200
.stackreserve 0x00100000
.subsystem 0x0003 // WINDOWS_CUI
.corflags 0x00000001 // ILONLY
// Image base: 0x018E0000
- 26. 最適化スイッチ(/optimize /debug) P15
/optimize /debug IL最適化 JIT最適化
- - × ○ IL読書用
- (+ | full | pdbonly) × × Debugビルド
+ どれでも ○ ○ Releaseビルド
Edit & Continue用
/optimize-
Nop / 分岐命令
.pdbファイルの生成
/debug+
デバッグ可能属性の付与→JITへの通知
- 28. アセンブリの依存関係
dumpbin /DEPENDENTS a.exe
mscoree.dll にのみ依存している。
x86
C:¥Windows¥System32
X64, IA64
64ビット版:C:¥Windows¥System32
32ビット版:C:¥Windows¥SysWoW64
- 29. アセンブリのロード
• Fx4.0からは、mscoreei.dllが追加されている
.NET Framework 2.0
%systemroot%¥ %windir%¥Framework¥v2.x¥
a20.exe mscoree.dll mscorwks.dll
Shim
.NET Framework 4.0
%systemroot%¥ %windir%¥Framework¥v4.x¥ %windir%¥Framework¥v4.x¥
a40.exe mscoree.dll mscoreei.dll clr.dll
Shim
- 30. Shim
Assembly
CLR
Shim
= mscoree.dll
- 33. 起動
• CLR初期化
– AppDomainの作成
• EXEアセンブリのロード
• エントリー・ポイント・メソッド呼び出し