【发布时间】:2010-03-04 16:12:02
【问题描述】:
我正在尝试开发一个 Web 应用程序,该应用程序可根据每个请求向另一个 Web 应用程序的多个版本分派 (Dispatcher)。为此,我正在使用ApplicationManager.CreateObject 创建新的 AppDomains,运行相关的 Web 应用程序,但新的应用程序域似乎无法加载 Dispatcher 的 DLL(我正在将 DLL 复制到 Web 应用程序的bin 目录,所以我很确定它在那里)。
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);
这是融合日志:
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.
Appbase 似乎指向开发服务器的根目录,而不是传递给 ApplicationManager.CreateObject 的路径,而且它似乎只是在开发服务器下搜索目录,这似乎很奇怪。关于如何让新的 AppDomain 在 Web 应用程序的根目录中而不是在开发服务器下搜索 DLL 的任何想法?
【问题讨论】:
标签: .net asp.net assemblies appdomain