The Exception Model

I had hoped this article would be on changes to the next version of the CLR which allow it to be hosted inside SQL Server and other “challenging” environments. This is more generally interesting than you might think, because it creates an opportunity for other processes (i.e. your processes) to host the CLR with a…


TransparentProxy

One of the recurring requests for a blog is related to TransparentProxy, RealProxy, Contexts, Interception, etc. As usual, I’m typing this where I don’t have access to our corporate network and the sources, so some details might be a little off. (When will my dentist provide free wireless to his customers?) And, as usual, none…


AppDomains (“application domains”)

An AppDomain is a light-weight process. Well, if you actually measure the costs associated with an AppDomain – especially the first one you create, which has some additional costs that are amortized over all subsequent ones – then “light-weight” deserves some explanation: A Win32 process is heavy-weight compared to a Unix process. A Win32 thread…


Memory Model

One of the suggestions for a blog entry was the managed memory model. This is timely, because we’ve just been revising our overall approach to this confusing topic. For the most part, I write about product decisions that have already been made and shipped. In this note, I’m talking about future directions. Be skeptical. So…


Value Types

The CLR’s type system includes primitive types like signed and unsigned integers of various sizes, booleans and floating point types. It also includes partial support for types like pointers and function pointers. And it contains some rather exotic beasts, like ArgIterators and TypedByRefs. (These are exotic because their lifetimes are restricted to a scope on…


Security and Asynchrony

In a comment to my last ramble, about asynchronous execution and pinning, someone asked for advice on using Windows impersonation in a managed application. Unfortunately, the managed platform currently has poor abstractions and infrastructure for controlling Windows identity, and indeed for most of the unmanaged Windows security system. For example, the managed classes for WaitHandles…


Asynchronous operations, pinning

One thing we tried to do with the CLR and FX is provide a consistent asynchronous programming model. To briefly recap the model, an API called XXX may also offer an async alternative composed of BeginXXX and EndXXX methods. Even if the class that implements XXX doesn’t also offer BeginXXX and EndXXX, you can define…


Interface layout

The CLR has two different techniques for implementing interfaces. These two techniques are exposed with distinct syntax in C#:   interface I { void m(); } class C : I { public virtual void m() {} // implicit contract matching } class D : I { void I.m() {} // explicit contract matching }  …


Virtual and non-virtual

The CLR type system supports both virtual and non-virtual instance methods.  And IL can contain both CALLVIRT and CALL instructions.  So it makes sense that IL generators would call virtual methods using CALLVIRT and call non-virtual instance methods with CALL. In fact, this is not necessarily the case. Either kind of call instruction can be applied to…


Interning Strings and immutability

Managed strings are subject to ‘interning’. This is the process where the system notices that the same string is used in several places, so it can fold all the references to the same unique instance. Interning happens two ways in the CLR.   It happens when you explicitly call System.String.Intern(). Obviously the string returned from…