简体   繁体   English

ApplicationManager.CreateObject无法在新的AppDomain中加载程序集

[英]ApplicationManager.CreateObject fails to load assembly in new AppDomain

I'm trying to develop a web application that dispatch (Dispatcher) to multiple versions of another webapp on a per-request basis. 我正在尝试开发一个Web应用程序,该Web应用程序可以根据请求将(Dispatcher)分发到另一个Webapp的多个版本。 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). 为此,我正在使用ApplicationManager.CreateObject来创建运行有问题的Web应用程序的新AppDomain,但是新的应用程序域似乎无法加载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);

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. Appbase似乎指向开发服务器的根目录,而不是传递到ApplicationManager.CreateObject的路径,它似乎只是在开发服务器下搜索目录,这似乎很奇怪。 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? 关于如何使新AppDomain在Web应用程序的根目录而不是在开发服务器下搜索DLL的任何想法?

It looks like (at least in our situation) this is the wrong way to go: Using a reverse proxy being the right way. 看起来(至少就我们而言)这是错误的方法:使用反向代理是正确的方法。

Reverse proxies have the advantage that they are a "pattern" in HTTP architecture and they save us from having to make sure that the ASP.NET runtime is really configured properly in the AppDomains running the actual web app. 反向代理的优势在于他们是在HTTP架构的“模式”,他们拯救我们不必确保ASP.NET运行时真的在运行实际的Web应用程序的AppDomain的正确配置。

We're currently looking at ProxyMachine which is a highly configurable TCP reverse proxy that GitHub seems to have had some success with . 我们目前正在研究ProxyMachine ,它是一个可高度配置的TCP反向代理, GitHub似乎在此方面取得了一些成功

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM