Ivan Krivyakov's Blog

Premature optimization is the root of all evil

February 23, 2008

.NET: no trace TextWriter…

I wanted to create a logger that writes either to a file, or to the System.Diagnostics.Trace. To my astonishment, I found that .NET class library does not have a TextWriter implementation that writes to the System.Diagnostics.Trace. Fortunately, it is relatively easy to create.

February 4, 2008

Unmanaged Hosting API Gotcha

I was playing with .NET 2.0 unmanaged hosting API. I am trying to customize assembly loading and “fix” some assemblies on the fly. I found an interesting gotcha, that I want to write down.

In one line: if you return a non-null value from IHostAssemblyManager::GetNonHostStoreAssemblies, then ICLRRuntimeHost::ExecuteInDefaultAppDomain returns error code 0×80131051 or FUSION_E_LOADFROM_BLOCKED, without ever consulting your assembly store, or the non-host store assemblies list.

[read more...]

.NET Assembly Format: Too Tight?

I am playing with the binary format of .NET assemblies, described here.

.NET metadata is stored inside regular Windows executable PE file. I explored PE file format in detail when I was working on the GenTestAsm project. There is one striking difference between PE and CLR:

PE is optimized for speed, CLR is optimized for size

[read more...]

February 3, 2008

Framework Design Guidelines Book – Part III

This is part three of the series.

Type Design (continued…)

p 89: Struct design: DO ensure that a state where all instance data is set to zero … is valid. This sounds reasonable, until they give an example. They consider a structure

[read more...]