I want to know the in-memory representation of .NET constructs such as “interface“, “class“, “struct“, etc. There’s an excellent book for C++ object model – <Inside the C++ Object Model> by Stanley. Lippman, I want a similar book for .NET and C#.
I have read some books about .NET, but they are mostly about the logical usage of .NET. None of them talks about the physical in-memory layout info. I think it’s necessary to know at least one implementation of .NET.
I have read about the “Drill Into .NET Framework Internals to See How the CLR Creates Runtime Objects” Could someone provide some hints about more in-depth books and articles?
If this info is not publicly avaialble. Shared source one like Mono or Shared Source CLI could be an option.
Many thanks.
The reason this information is not easily available is almost certainly deliberate on Microsofts behalf.
Microsoft created the .NET Framework and the CLR so you do not have to (unduly) worry yourself about where/how your objects are stored in memory (implmentation details). This “ignorance” is actually one of the biggest benefits of using .NET; you do not need to worry about issues such as manual memory allocation, processor/memory models etc.
The other benefit of this is that it improves security, ie it makes writing malicious code that much harder, although not impossible of course.
CLR Via C# by Jeff Richter is probably the best current book for “under the hood” type .NET information. Chapters 4, 5, 20 and 21 would probably be of most interest regarding layout of .NET types, although, as explained above, you will not find the same level of detail as the C++ object model.