# Monday, September 22, 2003

Suzanne Cook is a Microsoft developer who works on the assembly binding code within the .NET Framework.  She writes some fantastic blogs, right up there with Chris Brumme (though thankfully not as long!).  Fumiaki agrees that her content is top quality and that she's prepared to go out of her way to help solve problem, including replying to email on a Sunday night.

In a code review with Mark White from MCS last week we were looking at some code I'd written to dynamically load an assembly.  In the XP spirit of 'do the simplest thing that works' I had used Assembly.LoadWithPartialName to load in my assembly since I was working on a development version that wasn't strong named or signed.  However this is a bad idea because as Suzanne says, it's the pathway back to DLL Hell.  As she says:

Assembly.LoadWithPartialName() ... uses partial binding. ... A partial bind is when only part of the assembly display name is given when loading an assembly. ...  First, it calls Assembly.Load(). But, if that fails to find the assembly, it will return the latest version of that assembly available in the GAC.

So, in the end I changed to use Activator.CreateInstance.  This works with partial binding for now until I strong name the assembly when I can use the full assembly display name.  Here's a sketch of the code (minus the error handling):

// Get the type from the config file value
Type remoteAssembly = System.Type.GetType(remoteAssemblyTypeFromConfiigFile);
string assembly = remoteAssembly.Assembly.ToString();
string typeReference = remoteAssembly.FullName;
// Get an object handle to this type
ObjectHandle wrapper = Activator.CreateInstance(assembly, typeReference);
// Unwrape the object handle into the interface we need
IRemoteInterface remote = (IRemoteInterface)wrapper.Unwrap();

posted on Monday, September 22, 2003 8:56:55 AM (GMT Daylight Time, UTC+01:00)  #   
Related posts:
Office Server 2007: Can it help me write less code?
Server-side Excel: changing the face of financial apps?
Ray Ozzie: Services Disruption and the need for 'Client Server Service Synergy'
DDD3: Deadline for speaker submissions extended until Monday
DDD III on Sat 3 June: Call for Speakers!
I can see clearly now: NUnitAddin and NCoverBrowser
Tracked by:
"Slots" (Slots) [Trackback]
"blank+maps of europe" (blank+maps of europe) [Trackback]
"agnelli it" (agnelli it) [Trackback]
"riding-the bullet" (riding-the bullet) [Trackback]
"Black Jack" (Black Jack) [Trackback]
"Online Casinos" (Online Casinos) [Trackback]
"House Insurance" (House Insurance) [Trackback]
"Slot Machines" (Slot Machines) [Trackback]
"amplificatore-sintonizzatore" (amplificatore-sintonizzatore) [Trackback]
"honda finance center corporation" (honda finance center corporation) [Trackback]
"litfiba 17 re" (litfiba 17 re) [Trackback]
"traveleurope" (traveleurope ) [Trackback]
"big+girls lingerie" (big+girls lingerie ) [Trackback]
"change+pokemon silver time" (change+pokemon silver time ) [Trackback]
"finance-yahoo mortgage rates loan" (finance-yahoo mortgage rates loan ) [Trackback]
"living" (living) [Trackback]
"map+of bradford pennsylvania" (map+of bradford pennsylvania ) [Trackback]
"processo produzione farina grano" (processo produzione farina grano ) [Trackback]
"crescita bambino" (crescita bambino ) [Trackback]
"types+of alcoholismyouth alcoholism" (types+of alcoholismyouth alcoholism ) [Trackback]
"titolo+liverpool fc" (titolo+liverpool fc ) [Trackback]
"quote+cheap travel insurance" (quote+cheap travel insurance ) [Trackback]
"claus" (claus) [Trackback]
"cotten+panties" (cotten+panties ) [Trackback]
"Internet Roulette" (Internet Roulette) [Trackback]
"google" (google) [Trackback]
"dieta+razionale" (dieta+razionale ) [Trackback]
"SlotsMachines" (SlotsMachines) [Trackback]
"Home Owner Insurance" (Home Owner Insurance) [Trackback]
"Home Owner Insurence" (Home Owner Insurence) [Trackback]
"passo pordoi com" (passo pordoi com) [Trackback]
"focale" (focale) [Trackback]
"wildteen blowjobs" (wildteen blowjobs) [Trackback]
"shakiraporn naked" (shakiraporn naked) [Trackback]
"comprarelle azione" (comprarelle azione) [Trackback]
"blog" (blog) [Trackback]
"blog" (blog) [Trackback]
"authentic amateur sex videos" (authentic amateur sex videos) [Trackback]
"authenticamateur sex videos" (authenticamateur sex videos) [Trackback]
"barber chair sex" (barber chair sex) [Trackback]
"scienze" (scienze) [Trackback]
"calze" (calze) [Trackback]
"immobiliare villasimius" (immobiliare villasimius) [Trackback]