I'm trying to develop a web application that dispatch (Dispatcher) to multiple versions of another webapp on a per-request basis. To to that end, I'm using ApplicationManager.CreateObject to create new AppDomains running the web app in question, but the new app domains seem to be failing to load the Dispatcher's DLL (and I'm copying the DLL over to the web app's bin directory, so I'm pretty sure it's there).
var version = "version";
var path = @"C:\code\devel\webapp";
// Copy host assembly to target webapp so that 'Host' is available
var assembly = Assembly.GetExecutingAssembly().Location;
var target = path + "\\bin\\" + Path.GetFileName(assembly);
File.Copy(assembly, target, true);
var manager = ApplicationManager.GetApplicationManager();
var obj = manager.CreateObject(version, typeof(Host), "/", path, true, true);
Here's the fusion log:
Assembly manager loaded from: c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
Running under executable C:\Program Files (x86)\Common Files\Microsoft Shared\DevServer\9.0\WebDev.WebServer.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: User = FOOBAR\aaron
LOG: DisplayName = Dispatcher, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
(Fully-specified)
LOG: Appbase = file:///C:/Program Files (x86)/Common Files/Microsoft Shared/DevServer/9.0/
LOG: Initial PrivatePath = NULL
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using machine configuration file from c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Common Files/Microsoft Shared/DevServer/9.0/Dispatcher.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Common Files/Microsoft Shared/DevServer/9.0/Dispatcher/Dispatcher.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Common Files/Microsoft Shared/DevServer/9.0/Dispatcher.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Common Files/Microsoft Shared/DevServer/9.0/Dispatcher/Dispatcher.EXE.
The Appbase seems to be pointing at the root of the development server, rather than the path passed in to ApplicationManager.CreateObject and it only seems to be searching directories under the development server which seems strange. Any ideas on how to make the new AppDomain search for the DLL in the web app's root rather than under the development server?