这可能不是MVC特有的,它可能也适用于ASP.NET WebForms,但我们在MVC2上已经体验过它。使用组件化ASP.NET MVC应用程序可以顺利部署吗?
每当我们开始使用MSDeploy进行远程部署时,我们都会为我们的请求获取一个简短的(服务器错误)页面(5-6秒),直到发生新的部署。以下是错误文本:
'/'应用程序中的服务器错误。
无法加载文件或程序集 'Some.Assembly'或其某个 依赖项。该进程不能 访问该文件,因为它正在被其他进程使用的 。 (异常 从HRESULT:0x80070020)
描述:未处理的异常 的 当前web请求的执行过程中发生。请查看 堆栈跟踪以了解有关 错误的更多信息,以及它源自 的代码。
异常详细信息: System.IO.FileLoadException:无法 载荷文件或程序集Some.Assembly' 或它的一个依赖。 进程无法访问该文件,因为 它正在被另一个进程使用。 (来自HRESULT的例外:0x80070020)
版本信息:Microsoft .NET Framework版本: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)大会是不实际的网页组件,但其中的一个组件是它的“参考”,用.snk进行签名。
经过5-6秒后,网站上升,错误消失。
这当然不是理想的行为。我想知道我们是否在组件连接方面做错了什么。是否应该有另一种方法来确保顺利部署?或者这可能是MVC2本身的错误?
P.S.无论如何,IIS重叠旋转是启用的。
以下是组分:
- A.DLL
- Some.Assembly.dll(< ---这是发生故障的一个,取决于A.DLL)
- B.DLL(取决于A.dll和Some.Assembly.dll)
- Web。dll(这是网络应用程序,取决于上述所有内容)
所有的依赖关系都是使用启用Copy Local
的常规程序集引用来建立的。所有的DLL都是解决方案的一部分,作为单独的项目。
MSDeploy仅部署二进制文件,而不是源文件。
显示你如何组成网站将有所帮助。 – jfar 2010-12-23 17:55:30
@jfar:完成了。 – 2010-12-23 18:04:44
所以你不在运行时加载组件? – jfar 2010-12-23 18:27:11