Note: This article was originally
published in August 2004 on 15Seconds.com, but it has gotten good reviews, and
the techniques, I believe, are still valid. I hope the readers of ASPAlliance
find it as useful as I have.
In the first part of this series, we covered what it is that
the .NET Service Manager does as well as how to install and configure managed
services to run under it. In this part, we're going to cover the details of how
the .NET Service Manager works, that is, how it enables the great features such
as drag-n-drop deployment. Many of the concepts behind this can be abstracted
to apply to other .NET projects you may work on.
There are a few core technologies that made this facility
possible, which are .NET Remoting, AppDomains, Reflection, shadow copy, and
other standard object-oriented practices like classes and interfaces. The key
technology that enables the dynamic loading and, more importantly, unloading of
assemblies is Remoting; it allows us to completely load, host, and run code in
an isolated part of memory (an application domain, a.k.a., AppDomain) that for
all intents and purposes acts like a standard Windows process.