现在的位置: 首页 > 综合 > 正文

CS0016: 未能写入(A compilation error has occurred.HttpCompileException: error CS0016: Could not write to output file 拒绝访问)

2012年11月24日 ⁄ 综合 ⁄ 共 2899字 ⁄ 字号 评论关闭

项目部署一直挺好的,今天使用时,突然在日记中报错!

System.UnauthorizedAccessException: Access to the temp directory is denied. Identity 'IIS APPPOOL\zbs_Remoter_20104' under which XmlSerializer is running does not have sufficient permission to access the temp directory. CodeDom will use the user account the process is using to do the compilation, so if the user doesn�t have access to system temp directory, you will not be able to compile. Use Path.GetTempPath() API to find out the temp directory location.

Server stack trace:
at System.Xml.Serialization.Compiler.Compile(Assembly parent, String ns, XmlSerializerCompilerParameters xmlParameters, Evidence evidence)
at System.Xml.Serialization.TempAssembly.GenerateAssembly(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, Evidence evidence, XmlSerializerCompilerParameters parameters, Assembly assembly, Hashtable assemblies)
at System.Xml.Serialization.XmlSerializer.GetSerializersFromCache(XmlMapping[] mappings, Type type)
at System.Xml.Serialization.XmlSerializer.FromMappings(XmlMapping[] mappings, Type type)
………………

在浏览器中,页面返回如下错误信息:

error CS0016: Could not write to output file 'c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\62dbbf01\a08ea1a8\App_global.asax.qujxfrcb.dll' -- '拒绝访问。 ' at System.Web.Compilation.AssemblyBuilder.Compile() at System.Web.Compilation.BuildProvidersCompiler.PerformBuild() at System.Web.Compilation.ApplicationBuildProvider.GetGlobalAsaxBuildResult(Boolean isPrecompiledApp) at System.Web.Compilation.BuildManager.CompileGlobalAsax() 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)
……………………
at System.Web.Compilation.AssemblyBuilder.Compile() at System.Web.Compilation.BuildProvidersCompiler.PerformBuild() at System.Web.Compilation.ApplicationBuildProvider.GetGlobalAsaxBuildResult(Boolean isPrecompiledApp) at System.Web.Compilation.BuildManager.CompileGlobalAsax() 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)

很是奇怪,竟然提示:

CS0016: Could not write to output file 'c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\62dbbf01\a08ea1a8\App_global.asax.qujxfrcb.dll' -- '拒绝访问。 '

一直也没动过相关文件夹的权限啊!

既然说没有权限,就试着把Temporary ASP.NET Files权限提升,发现已经有了IIS_USERS权限了,难道还不够,索性就再给了Netword Services和Everyone所有权限,重启IIS后还是不行。然后我就把c:\Windows\Temp文件夹权限也提升和Temporary ASP.NET Files一样,再次重启IIS,访问站点,呃,竟然可以了!把Everyone权限移除也可以!

最后我不明所以,望高人指点,这样设置也太没有安全性可言了!

注:只要设置C:\Windows\Temp的权限就可以了!!!

抱歉!评论已关闭.