[英]ASP.NET 4 App dll is shadow copied but bin dll is loaded instead
Having a very odd issue with a large asp.net 4 application. 在大型asp.net 4应用程序中存在一个非常奇怪的问题。 IIS will sometimes load modules not from the shadow copy location but instead the bin directory where the dlls are originally sourced from.
IIS有时不是从卷影副本位置加载模块,而是从dll最初来自的bin目录加载。
Does anyone know how the IIS module loading works and whether this is normal behaviour or a bug? 有谁知道IIS模块加载的工作方式,这是正常现象还是错误?
Problems this is causing us 这是导致我们的问题
Notes 笔记
Discovered the root cause of this issue a few weeks ago, posting now to hopefully help anyone who suffers from anything similar. 几周前发现了此问题的根本原因,希望现在发布以帮助遭受类似问题的任何人。
After a couple aha moments from a few of our devs we discovered that this was self-inflicted by the way that we were scanning dlls for nhibernate configurations. 在我们的一些开发人员经过一番努力之后,我们发现这是由于我们在扫描dll进行nhibernate配置时所造成的。
When we were explicitly loading the dlls from code we were misusing the Assembly
helper methods. 当我们从代码中显式加载dll时,我们滥用了
Assembly
helper方法。 Instead of using Assembly.LoadFrom(assemblyPath)
we were using Assembly.LoadFile(assemblyPath)
. 而不是使用
Assembly.LoadFrom(assemblyPath)
而是使用Assembly.LoadFile(assemblyPath)
。 There are a bunch of differences between these methods, relevant here is that LoadFile()
loads the specified file whereas LoadFrom()
will apply logic for finding the assembly from other locations such as temp, cache or GAC. 这些方法之间存在许多差异,此处相关的是
LoadFile()
加载指定的文件,而LoadFrom()
将应用逻辑以从其他位置(如temp,cache或GAC LoadFrom()
查找程序集。 See this question for more details of the differences. 有关差异的更多详细信息,请参见此问题 。
Anyway, after changing this single line of code, all of our problems disappeared. 无论如何,在更改了这一行代码之后,我们所有的问题都消失了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.