“ /”应用程序文件加载异常中的服务器错误

时间:2019-08-07 11:53:02

标签: c# dll azure-devops azure-web-sites

尝试打开网站时出现错误。它在Visual Studio中运行良好,在本地发布时也运行良好,但是在Azure Devops中构建时会出现此错误:

Server Error in '/' Application.
Could not load file or assembly 'file:///D:\home\site\wwwroot\bin\App_Web_orhmujnn.dll' or one of its dependencies. Access is denied.

这是堆栈跟踪:

[FileLoadException: Could not load file or assembly 'file:///D:\home\site\wwwroot\bin\App_Web_orhmujnn.dll' or one of its dependencies. Access is denied.]
 System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
 System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +36
 System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +152
 System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark) +102
 System.Reflection.Assembly.LoadFrom(String assemblyFile) +34
 WebActivatorEx.ActivationManager.get_Assemblies() +187
 WebActivatorEx.ActivationManager.RunActivationMethods(Boolean designerMode) +97
 WebActivatorEx.ActivationManager.RunPreStartMethods(Boolean designerMode) +36
 WebActivatorEx.ActivationManager.Run() +75

[InvalidOperationException: The pre-application start initialization method Run on type webActivatorEx.ActivationManager threw and exceoption with the following error message: Could not load file or assembly 'file:///D: \home\site\wwroot\bin\App_web_orhmujnn.dll' or one of its dependencies. Access id denied..]
 System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods, Func`1 setHostingEnvironmentCultures) +613
 System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +138
 System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +164
 System.Web.Compilation.BuildManager.ExecutePreAppStart() +156
 System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +695


[HttpException (0x80004005): The pre-application start initialization method Run on type WebActivatorEx.ActivationManager threw an exception with the following error message: Could not load file or assembly 'file:///D:\home\site\wwwroot\bin\App_Web_orhmujnn.dll' or one of its dependencies. Access is denied..]
 System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +656
 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +89
 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +189

在页面上执行Ctrl + F5有时会返回不同的dll,但大部分错误未更改

我已经检查了Azure Devops的构建设置,并与以前工作的构建相匹配。 Web配置和csproj也与以前工作的版本匹配。我还检查了我以外的PC上的站点,并且发生了相同的错误

1 个答案:

答案 0 :(得分:1)

清除wwwroot \ bin中的所有内容后,重新构建后便解决了该问题。 Azure上的App Service中有一个控制台,可以清空目录