这是我在SO中的第一个问题,如果我在语法上有误,请向我道歉。
问题描述:
我拥有基于IIS 7(Windows Server 2008)和SQL Server 2008 R2的32位基于MVC 5的CRUD系统,该系统已安装到多台服务器中,自2015年8月以来提供公司内部网管理服务。
数月以来,它们全部运行平稳,没有任何问题。但是,昨天我发现我无法使用以下消息访问172.16.1.101服务器上的站点根页面:
> Server Error in '/' Application.
> [Win32Exception (0x80004005): Access is denied]
>[ExternalException (0x80004005): Cannot execute a program. The command being executed was "C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe" /noconfig /fullpaths @"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\-(random 8-digit hex)-\-(random 8-digit hex)-\-(random 8-char base64).cmdline".]
System.CodeDom.Compiler.Executor.ExecWaitWithCaptureUnimpersonated(SafeUserTokenHandle userToken, String cmd, String currentDir, TempFileCollection tempFiles, String& outputName, String& errorName, String trueCmdLine) +3365
System.CodeDom.Compiler.Executor.ExecWaitWithCapture(SafeUserTokenHandle userToken, String cmd, String currentDir, TempFileCollection tempFiles, String& outputName, String& errorName, String trueCmdLine) +8591876
Microsoft.CSharp.CSharpCodeGenerator.Compile(CompilerParameters options, String compilerDirectory, String compilerExe, String arguments, String& outputFile, Int32& nativeReturnValue, String trueArgs) +331
Microsoft.CSharp.CSharpCodeGenerator.FromFileBatch(CompilerParameters options, String[] fileNames) +784
Microsoft.CSharp.CSharpCodeGenerator.System.CodeDom.Compiler.ICodeCompiler.CompileAssemblyFromFileBatch(CompilerParameters options, String[] fileNames) +170
System.Web.Compilation.AssemblyBuilder.Compile() +12440424
System.Web.Compilation.BuildProvidersCompiler.PerformBuild() +303
System.Web.Compilation.ApplicationBuildProvider.GetGlobalAsaxBuildResult(Boolean isPrecompiledApp) +12978145
System.Web.Compilation.BuildManager.CompileGlobalAsax() +50
System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +665
>[HttpException (0x80004005): Cannot execute a program. The command being executed was "C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe" /noconfig /fullpaths @"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\-(random 8-digit hex)-\-(random 8-digit hex)-\-(random 8-char base64)-.cmdline".]
System.Web.Compilation.BuildManager.ReportTopLevelCompilationException() +80
System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +1142
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +1193
>[HttpException (0x80004005): Cannot execute a program. The command being executed was "C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe" /noconfig /fullpaths @"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\-(random 8-digit hex)-\-(random 8-digit hex)-\-(random 8-char base64)-.cmdline".]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12980692
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +12820285
这是发生异常时的事件日志:
>IIS 7 Event Log
>Event code: 3005
>Event message: An unhandled exception has occurred.
>Event time: 5/24/2016 1:42:08 PM
>Event time (UTC): 5/24/2016 6:42:08 AM
>Event ID: 062751a2dc724be9af5de99014e58a47
>Event sequence: 2
>Event occurrence: 1
>Event detail code: 0
>Application information:
>Application domain: /LM/W3SVC/3/ROOT-1-131085457263004464
>Trust level: Full
>Application Virtual Path: /
>Application Path: E:\Test\
>Machine name: -- edited --
>Process information:
>Process ID: 1172
>Process name: w3wp.exe
>Account name: IIS APPPOOL\ASP.NET v4.0
>Exception information:
>Exception type: HttpException
>Exception message: Cannot execute a program. The command being executed was "C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe" /noconfig /fullpaths @"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\-(random 8-digit hex)-\-(random 8-digit hex)-\-(random 8-char base64)-.cmdline".
at System.Web.Compilation.BuildManager.ReportTopLevelCompilationException()
at System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled()
at System.Web.Compilation.BuildManager.CallAppInitializeMethod()
at System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException)
>Cannot execute a program. The command being executed was "C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe" /noconfig /fullpaths @"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\-(random 8-digit hex)-\-(random 8-digit hex)-\-(random 8-char base64).cmdline".
at System.CodeDom.Compiler.Executor.ExecWaitWithCaptureUnimpersonated(SafeUserTokenHandle userToken, String cmd, String currentDir, TempFileCollection tempFiles, String& outputName, String& errorName, String trueCmdLine)
at System.CodeDom.Compiler.Executor.ExecWaitWithCapture(SafeUserTokenHandle userToken, String cmd, String currentDir, TempFileCollection tempFiles, String& outputName, String& errorName, String trueCmdLine)
at Microsoft.CSharp.CSharpCodeGenerator.Compile(CompilerParameters options, String compilerDirectory, String compilerExe, String arguments, String& outputFile, Int32& nativeReturnValue, String trueArgs)
at Microsoft.CSharp.CSharpCodeGenerator.FromFileBatch(CompilerParameters options, String[] fileNames)
at Microsoft.CSharp.CSharpCodeGenerator.System.CodeDom.Compiler.ICodeCompiler.CompileAssemblyFromFileBatch(CompilerParameters options, String[] fileNames)
at System.CodeDom.Compiler.CodeDomProvider.CompileAssemblyFromFile(CompilerParameters options, String[] fileNames)
at System.Web.Compilation.AssemblyBuilder.Compile()
at System.Web.Compilation.BuildProvidersCompiler.<PerformBuild>b__1(AssemblyBuilder assemblyBuilder)
at System.Threading.Tasks.Parallel.<>c__DisplayClass32`2.<PartitionerForEachWorker>b__30()
at System.Threading.Tasks.Task.InnerInvoke()
at System.Threading.Tasks.Task.InnerInvokeWithArg(Task childTask)
at System.Threading.Tasks.Task.<>c__DisplayClass11.<ExecuteSelfReplicating>b__10(Object param0)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Web.Compilation.BuildProvidersCompiler.PerformBuild()
at System.Web.Compilation.CodeDirectoryCompiler.GetCodeDirectoryAssembly(VirtualPath virtualDir, CodeDirectoryType dirType, String assemblyName, StringSet excludedSubdirectories, Boolean isDirectoryAllowed)
at System.Web.Compilation.BuildManager.CompileCodeDirectory(VirtualPath virtualDir, CodeDirectoryType dirType, String assemblyName, StringSet excludedSubdirectories)
at System.Web.Compilation.BuildManager.CompileResourcesDirectory()
at System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled()
>Access is denied
>Request information:
>Request URL: //172.16.1.101/
>Request path: /
>User host address: //172.16.1.101
>User:
>Is authenticated: False
>Authentication Type:
>Thread account name: IIS APPPOOL\ASP.NET v4.0
>Thread information:
>Thread ID: 5
>Thread account name: IIS APPPOOL\ASP.NET v4.0
>Is impersonating: True
>Stack trace: at >System.Web.Compilation.BuildManager.ReportTopLevelCompilationException()
at System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled()
at System.Web.Compilation.BuildManager.CallAppInitializeMethod()
at System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException)
>Custom event details:
有时消息显示\Temporary ASP.NET Files\tls目录,而不是\Temporary ASP.NET Files\root目录。
IIS 7服务器配置为其默认状态和单个池,默认情况下不包含任何运行的Web服务(仅基本配置),包括XML(反序列化器)。
最初以为我在IIS系统帐户上有权限错误,所以我已经完成了将权限设置为“完全控制”的操作,但没有成功。
因此,根据消息,预期在服务器端缺少文件编译,试图通过此命令在CMD上手动编译cmdline文件
提供错误:
不会放弃,我对这个问题进行了谷歌搜索,并在SO上找到了相关的类似问题:
Problems publishing a website on smarterasp.net with csc.exe file included?
https://stackoverflow.com/questions/37146958/an-unhandled-exception-was-generated-during-the-execution-of-the-current-web-re
但是,我既没有安装“Microsoft.CodeDom.Providers.DotNetCompilerPlatform”包,也没有在为实时服务器实现编译项目时使用SOAP,并且在web.config上已经具有“identity impersonate =“true”'属性,但没有任何帮助。
接下来,我使用“高级设置”选项配置了与站点相对应的IIS应用程序池,将“身份”部分从“ApplicationPoolIdentity”更改为“LocalSystem”,有趣的是,访问根页面时的YSOD消失了。我试图将其改回“ApplicationPoolIdentity”,然后YSOD转回去。
即使通过LocalSystem身份临时解决了问题,我仍然很好奇为什么在没有任何系统故障迹象的情况下发生了错误。我想在这里问2个问题:
tl;博士:在IIS 7服务器上使用默认配置的ApplicationPoolIdentity起作用,直到昨天,我在没有应用XML序列化程序或Web服务的服务器上遇到了上述的YSOD,请帮助我解释或描述服务器中已经发生了什么问题。细节及其缓解方法。
PS:在书面目录路径上,“-”和“-”符号应替换为“\”。
最佳答案
从nuget包中卸载DotNetCompilerPlatform