I'm reading Advanced .NET Debugging book and I like it very much. However I have some problems with the examples. I would really appreciate if someone that has read it helped me.
I have two questions:
Versus what version of .NET framework are examples built? I cannot run them under windbg(x86) and they load under windbg(x64) so I assume it's 64 bit version of framework. But which framework? 2.0, 3, 3.5, 4?
When looking at type handle (method table) as described in Chapter 2 I had different results (my results and what book shows is shown below). Of course I'm not talking about addresses being different. For example when I dd on method table I see different values for Flags2 field, NumMethods field. I have no idea why. On page 56 author says that size of object is 0x14 (same at my machine) because object has 4 integers. But listing for 02TypeSample.cs shows only 3 integers, x, y, z. On my machine dd shows 4 methods when in example it shows 7. Book also says that compiler generated default ctor.
"The first thing to remember is that even though we did not explicitly define any constructors, the C# compiler automatically generated a default constructor for us.
When on listing you can see that TypeSample has ctor taking 3 integers as parameters. Either something is wrong with me, book or examples. What is it? ;)
Method table from the book:
0:000>dd 002930b0
002930b0 00040000 00000014 00070402 00000004
002930c0 790fd0f0 00292c3c 002930f8 00291244
002930d0 00000000 00000000 79371278 7936b3b0
002930e0 7936b3d0 793624d0 003400c8 0029c015
002930f0 0034007000000000 00000080 00000000
00293100 00000000 00000000 00000000 00000000
00293110 00000000 00000000 00000000 00000000
00293120 00000000 00000000 00000000 00000000
My method table:
0:000> dd 00223420
00223420 00000000 00000014 00040011 00000004
00223430 68b70944 00222fe4 00223458 00221390
00223440 00000000 00000000 68ac6a90 68ac6ab0
00223450 68ac6b20 68b37700 00000080 00000000
00223460 00000000 00000000 00000000 00000000
00223470 00000000 00000000 00000000 00000000
00223480 00000000 00000000 00000000 00000000
00223490 00000000 00000000 00000000 00000000
it shows 4 methods when !dumpmt shows 7
0:000> !dumpmt -md 00223420
EEClass: 00221390
Module: 00222fe4
Name: Advanced.NET.Debugging.Chapter2.TypeSample
mdToken: 02000002 (F:\Development\Advanced .NET Debugging\adndsrc\Chapter2\TypeSample\TypeSample\bin\Debug\TypeSample.exe)
BaseSize: 0x14
ComponentSize: 0x0
Number of IFaces in IFaceMap: 0
Slots in VTable: 7
--------------------------------------
MethodDesc Table
Entry MethodDesc JIT Name
68ac6a90 6894494c PreJIT System.Object.ToString()
68ac6ab0 68944954 PreJIT System.Object.Equals(System.Object)
68ac6b20 68944984 PreJIT System.Object.GetHashCode()
68b37700 689449a8 PreJIT System.Object.Finalize()
003d00d8 00223398 JIT Advanced.NET.Debugging.Chapter2.TypeSample..ctor(Int32, Int32, Int32)
0022c015 002233a4 NONE Advanced.NET.Debugging.Chapter2.TypeSample.AddCoordinates()
003d0070 002233b0 JIT Advanced.NET.Debugging.Chapter2.TypeSample.Main(System.String[])