Chris Brumme's Weblog

  • A quick update on me.
  • It’s been over two years since I blogged. Although I remain happily (perhaps even ecstatically) working at Microsoft, I left the CLR team and the Developer Division about a year ago. I’m now on an incubation team, exploring evolution and revolution i... Read More
  • Posted Friday, December 15, 2006 5:55 PM by cbrumme
  • Updated Finalization and Hosting
  • My original posts on Finalization and Hosting had some hokey XXXXX markers in place of content, where that content hadn’t already been disclosed in some form. Now that the Visual Studio 2005 Community Preview is available, I’ve gone back to those two ... Read More
  • Posted Monday, April 26, 2004 5:58 PM by cbrumme
  • Hosting
  • My prior three blogs were supposed to be on Hosting. Each time I got side tracked, first on Exceptions, then on Application Compatibility and finally on Finalization. I refuse to be side tracked this time… much. Also, I need to explain why it’s take... Read More
  • Posted Saturday, February 21, 2004 9:28 AM by cbrumme
  • Finalization
  • Earlier this week, I wrote an internal email explaining how Finalization works in V1 / V1.1, and how it has been changed for Whidbey. There’s some information here that folks outside of Microsoft might be interested in. Costs Finalization is expensi... Read More
  • Posted Friday, February 20, 2004 9:27 PM by cbrumme
  • Apartments and Pumping in the CLR
  • I’ve already written the much-delayed blog on Hosting, but I can’t post it yet because it mentions a couple of new Whidbey features, which weren’t present in the PDC bits. Obviously Microsoft doesn’t want to make product disclosures through my random ... Read More
  • Posted Monday, February 2, 2004 10:52 AM by cbrumme
  • The PDC and Application Compatibility, but still no Hosting
  • The PDC has happened, which means two things. I can post some of my (slightly self-censored) reactions to the show, and I can talk about what we ve disclosed about Whidbey and Longhorn more freely. In this particular case, I had promised to talk abou... Read More
  • Posted Monday, November 10, 2003 11:00 AM by cbrumme
  • 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 ... Read More
  • Posted Wednesday, October 1, 2003 1:18 PM by cbrumme
  • Startup, Shutdown and related matters
  • Usually I write blog articles on topics that people request via email or comments on other blogs. Well, nobody has ever asked me to write anything about shutdown. But then I look at all the problems that occur during process shutdown in the unmanaged... Read More
  • Posted Wednesday, August 20, 2003 11:51 AM by cbrumme
  • 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. (Whe... Read More
  • Posted Monday, July 14, 2003 3:58 PM by cbrumme
  • Reliability
  • I’ve been putting off writing this blog, not just because I’m on vacation in Maui and have far more tempting things to do. It’s because one of my blogs has already been used on Slashdot as evidence that Windows cannot scale and won’t support distribut... Read More
  • Posted Monday, June 23, 2003 12:51 PM by cbrumme
  • Infrequent blogging
  • Just a quick explanation for why there hasn’t been a new blog lately. I’m partway through a 3.5 week vacation on Maui. I have wireless & broadband out by the pool, but I can’t seem to find the time to blog. Things will return to normal by mid-Ju... Read More
  • Posted Monday, June 16, 2003 12:50 PM by cbrumme
  • 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” deser... Read More
  • Posted Sunday, June 1, 2003 12:21 PM by cbrumme
  • 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 sh... Read More
  • Posted Saturday, May 17, 2003 6:56 PM by cbrumme
  • 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 b... Read More
  • Posted Saturday, May 10, 2003 6:33 PM by cbrumme
  • 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 cont... Read More
  • Posted Thursday, May 8, 2003 10:28 PM by cbrumme
  • Request a topic
  • If there’s a topic related to the CLR, feel free to drop me a line asking me to talk about it. I have a very time-consuming day job and a full life outside of work, so expect a long delay before I address your topic. Or I might feel I have nothing in... Read More
  • Posted Thursday, May 8, 2003 11:06 AM by cbrumme
  • 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 imp... Read More
  • Posted Tuesday, May 6, 2003 9:41 PM by cbrumme
  • 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... Read More
  • Posted Saturday, May 3, 2003 6:56 PM by cbrumme
  • 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 w... Read More
  • Posted Friday, April 25, 2003 2:42 PM by cbrumme
  • 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... Read More
  • Posted Tuesday, April 22, 2003 6:16 PM by cbrumme
  • Lifetime, GC.KeepAlive, handle recycling
  • It’s not possible to state exactly when a managed object will be collected. The garbage collector schedules itself based on various heuristics. Even if a garbage collection occurs, it may only collect the younger generations of the heap. And the JIT... Read More
  • Posted Thursday, April 17, 2003 3:18 PM by cbrumme
  • Managed blocking
  • What’s the difference between WaitHandle.WaitOne/WaitAny/WaitAll and just PInvoke’ing to WaitForSingleObject or WaitForMultipleObjects directly? Plenty. There are several reasons why we prefer you to use managed blocking through WaitHandle or similar... Read More
  • Posted Thursday, April 17, 2003 9:57 AM by cbrumme
  • ReleaseComObject
  • Developers who are accustomed to the IDisposable pattern or to C#’s ‘using’ syntax sometimes ask why COM Interop doesn’t support IDisposable on every Runtime Callable Wrapper (RCW). That way, managed code could indicate that it is finished using the u... Read More
  • Posted Wednesday, April 16, 2003 12:51 PM by cbrumme
  • Threads, fibers, stacks and address space
  • Every so often, someone tries to navigate from a managed System.Threading.Thread object to the corresponding ThreadId used by the operating system. System.Diagnostic.ProcessThread exposes the Windows notion of threads. In other words, the OS threads ... Read More
  • Posted Tuesday, April 15, 2003 6:45 PM by cbrumme
  • Initializing code
  • A common question is how to initialize code before it is called. In the unmanaged world, this is done with a DLL_PROCESS_ATTACH notification to your DllMain routine. Managed C++ can actually use this same technique. However, it has all the usual res... Read More
  • Posted Tuesday, April 15, 2003 5:24 PM by cbrumme
  • Unhandled exceptions
  • There are two kinds of threads executing inside managed code: the ones we start in managed code and the ones that wander into the CLR. The ones that started in managed code include all calls to Thread.Start(), the managed threadpool threads, and the ... Read More
  • Posted Tuesday, April 15, 2003 2:49 PM by cbrumme
  • Inheriting from MarshalByRefObject
  • Developers often wonder why they are forced to derive from MarshalByRefObject or EnterpriseServices.ServicedComponent. It would be so much more convenient if they could add a CustomAttribute to their class or use a marker interface to declare that the... Read More
  • Posted Tuesday, April 15, 2003 2:22 PM by cbrumme
  • Managed objects and COM
  • All managed objects other than those derived from ServicedComponent, when exposed to COM, behave as if they have aggregated the free threaded marshaler (FTM). In other words, they can be called on any thread without any cross-apartment marshaling. Al... Read More
  • Posted Tuesday, April 15, 2003 2:14 PM by cbrumme
  • Why don't metaobjects marshal by reference?
  • Objects that derive from MarshalByRefObject will marshal by reference rather than value. Metaobjects like Assembly, Type and MethodInfo do not derive from MarshalByRefObject. This is because we don’t want Type to be marshal by ref, which implies that... Read More
  • Posted Tuesday, April 15, 2003 1:47 PM by cbrumme
  • Surprising 'protected' behavior
  • There’s a subtle but important difference between protected access in unmanaged C++ and protected access (i.e. family) in the CLR. The difference is due to the CLR’s ability to build security guarantees on top of type safety. Imagine you had a bifurc... Read More
  • Posted Tuesday, April 15, 2003 1:35 PM by cbrumme
  • What is SEHException?
  • One way you get this exception is if unmanaged code does an OS RaiseException() or causes a fault. If that exception is propagated up the stack to managed code, we will try to map it to a managed exception. For example, STATUS_NO_MEMORY maps to OutOf... Read More
  • Posted Tuesday, April 15, 2003 1:31 PM by cbrumme
  • Size of a managed object
  • We don’t expose the managed size of objects because we want to reserve the ability to change the way we lay these things out. For example, on some systems we might align and pack differently. For this to happen, you need to specify tdAutoLayout for t... Read More
  • Posted Tuesday, April 15, 2003 1:11 PM by cbrumme
  • DLL exports
  • People often ask how they can expose traditional DLL exports from managed assemblies. Managed C++ makes it very easy to export functions. And you could use tricks like ILDASM / ILASM to inject DLL exports into managed assemblies built with other lang... Read More
  • Posted Tuesday, April 15, 2003 12:59 PM by cbrumme
  • Hyper threading
  • If the operating system schedules multiple threads against a hyper-threaded CPU, the CLR automatically takes advantage of this. This is certainly the case for new versions of the OS like Windows Server 2003. Also, the CLR did work to properly spin on... Read More
  • Posted Tuesday, April 15, 2003 12:22 PM by cbrumme
  • Turning off the garbage collector
  • It is not generally possible to turn off garbage collection. However, the garbage collector won’t run unless “provoked.” Garbage collection is triggered by: Allocation Explicit calls by the application to System.GC.Collect ... Read More
  • Posted Tuesday, April 15, 2003 12:10 PM by cbrumme
  • Error C0020001
  • #define BOOTUP_EXCEPTION_COMPLUS 0xC0020001 You may see an exception with this code, or an HRESULT of this value, when trying to call into managed code. This can happen if you call in before the runtime has finished initializing, or after the runtim... Read More
  • Posted Tuesday, April 15, 2003 11:54 AM by cbrumme
  • Static Fields
  • By default, static fields are scoped to AppDomains. In other words, each AppDomain gets its own copy of all the static fields for the types that are loaded into that AppDomain. This is independent of whether the code was loaded as domain-neutral or n... Read More
  • Posted Tuesday, April 15, 2003 11:41 AM by cbrumme