【发布时间】:2011-05-30 02:29:29
【问题描述】:
这可能不是 MVC 特定的,它也可能适用于 ASP.NET WebForms,但到目前为止我们一直在 MVC2 上体验它。
每当我们开始使用 MSDeploy 进行远程部署时,我们都会收到一个简短的(5-6 秒)“服务器错误”页面来处理我们的请求,直到进行新的部署。这是错误文本:
“/”应用程序中的服务器错误。
无法加载文件或程序集 'Some.Assembly' 或其之一 依赖关系。进程不能 访问该文件,因为它正在 被另一个进程使用。 (例外 从 HRESULT: 0x80070020)
描述:未处理的异常 在执行过程中发生 当前的网络请求。请查看 堆栈跟踪以获取有关的更多信息 错误及其起源 代码。
异常详情: System.IO.FileLoadException:不能 加载文件或程序集“Some.Assembly” 或其依赖项之一。这 进程无法访问该文件,因为 它正被另一个进程使用。 (HRESULT 异常:0x80070020)
版本信息:Microsoft .NET 框架版本:4.0.30319; ASP.NET 版本:4.0.30319.1
这是错误页面中显示的堆栈跟踪:
[FileLoadException: Could not load file or assembly 'Some.Assembly' or one of its dependencies. The process cannot access the file because it is being used by another process. (Exception from HRESULT: 0x80070020)]
System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +39
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks) +132
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +144
System.Reflection.Assembly.Load(String assemblyString) +28
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +46
[ConfigurationErrorsException: Could not load file or assembly 'Some.Assembly' or one of its dependencies. The process cannot access the file because it is being used by another process. (Exception from HRESULT: 0x80070020)]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +618
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +209
System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +130
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +178
System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +94
System.Web.Compilation.BuildManager.CallPreStartInitMethods() +332
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +591
[HttpException (0x80004005): Could not load file or assembly 'Some.Assembly' or one of its dependencies. The process cannot access the file because it is being used by another process. (Exception from HRESULT: 0x80070020)]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +8950644
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +97
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +256
导致该故障的程序集 (Some.Assembly) 不是实际的 Web 程序集,而是它的“参考”下的其他组件之一,用 .snk 签名。
5-6 秒后,网站启动,错误消失。
这当然不是我们想要的行为。我想知道我们在将组件连接在一起方面是否做错了什么。是否应该有另一种方法来确保顺利部署?或者这可能是 MVC2 本身的错误?
附: IIS 重叠旋转已启用,无论如何都是默认设置。
以下是组件:
- A.dll
- Some.Assembly.dll(
- B.dll(取决于 A.dll 和 Some.Assembly.dll)
- Web.dll(这是 Web 应用程序,取决于以上所有内容)
所有依赖项都是使用启用Copy Local 的常规程序集引用建立的。所有 dll 都是作为单独项目的解决方案的一部分。
MSDeploy 仅部署二进制文件,而不是源代码。
【问题讨论】:
-
展示您如何使网站组成部分会很有帮助。
-
所以你不在运行时加载组件?
标签: asp.net asp.net-mvc iis-7