转自:http://www.pageadmin.net/article/20130305/537.html
IIS7 运行Asp.Net MVC WEB程序出错
错误描述:
“/”应用程序中的服务器错误。
编译错误
说明: 在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。
编译器错误消息: CS0016: 未能写入输出文件“c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ba060265\c782e097\App_global.asax.4djsb5yz.dll”--“拒绝访问。 ”
源错误:
[没有相关的源行] |
源文件: 行: 0
c:\windows\system32\inetsrv> "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe" /t:library /utf8output /R:"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ba060265\c782e097\assembly\dl3\daa73825\adb8eb61_a20fd001\Microsoft.Owin.Host.SystemWeb.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.CSharp\v4.0_4.0.0.0__b03f5f7f11d50a3a\Microsoft.CSharp.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_64\System.EnterpriseServices\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Activities\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Activities.dll" /R:"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ba060265\c782e097\assembly\dl3\4e2b3dc2\4658e161_a20fd001\Microsoft.Owin.dll" /R:"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ba060265\c782e097\assembly\dl3\1b283bff\9aafb761_a20fd001\Microsoft.AspNet.Identity.Core.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ComponentModel.DataAnnotations\v4.0_4.0.0.0__31bf3856ad364e35\System.ComponentModel.DataAnnotations.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll" /R:"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ba060265\c782e097\assembly\dl3\589fd8ac\f0cb055f_a20fd001\System.Web.Razor.dll" /R:"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ba060265\c782e097\assembly\dl3\2f79b788\c4011462_a20fd001\Microsoft.Owin.Security.Google.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.Services\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Web.Services.dll" /R:"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ba060265\c782e097\assembly\dl3\7c74de98\0241645f_a20fd001\System.Web.WebPages.Deployment.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.Extensions\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.Extensions.dll" /R:"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ba060265\c782e097\assembly\dl3\ffd0d5bc\7d08635f_a20fd001\System.Web.Helpers.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Activation\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Activation.dll" /R:"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ba060265\c782e097\assembly\dl3\307e0053\a851c861_a20fd001\Microsoft.AspNet.Identity.Owin.dll" /R:"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ba060265\c782e097\assembly\dl3\e7d2f243\24233a5f_a20fd001\System.Web.Optimization.dll" /R:"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ba060265\c782e097\assembly\dl3\d0c73558\be7cb85f_a20fd001\Newtonsoft.Json.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.DynamicData\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.DynamicData.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.WebPages.Deployment\v4.0_2.0.0.0__31bf3856ad364e35\System.Web.WebPages.Deployment.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_64\System.Web\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Web.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.ApplicationServices\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.ApplicationServices.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel\v4.0_4.0.0.0__b77a5c561934e089\System.ServiceModel.dll" /R:"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ba060265\c782e097\assembly\dl3\f2813b56\8b79d161_a20fd001\Microsoft.AspNet.Identity.EntityFramework.dll" /R:"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ba060265\c782e097\assembly\dl3\0eb90578\096af760_a20fd001\EntityFramework.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Data.DataSetExtensions\v4.0_4.0.0.0__b77a5c561934e089\System.Data.DataSetExtensions.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml.Linq\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.Linq.dll" /R:"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ba060265\c782e097\assembly\dl3\88c2e137\8df8d15f_a20fd001\Antlr3.Runtime.dll" /R:"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ba060265\c782e097\assembly\dl3\17fd6dd6\a007f561_a20fd001\Microsoft.Owin.Security.dll" /R:"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ba060265\c782e097\assembly\dl3\28668f51\1c93ef5f_a20fd001\WebGrease.dll" /R:"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\mscorlib.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.IdentityModel\v4.0_4.0.0.0__b77a5c561934e089\System.IdentityModel.dll" /R:"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ba060265\c782e097\assembly\dl3\093d8a6b\8ea2f860_a20fd001\EntityFramework.SqlServer.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.VisualStudio.Web.PageInspector.Loader\v4.0_1.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Web.PageInspector.Loader.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.WorkflowServices\v4.0_4.0.0.0__31bf3856ad364e35\System.WorkflowServices.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Web\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Web.dll" /R:"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ba060265\c782e097\assembly\dl3\09de7921\842a8b5f_a20fd001\System.Web.Mvc.dll" /R:"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ba060265\c782e097\assembly\dl3\c3fcd1bc\66120c62_a20fd001\Microsoft.Owin.Security.OAuth.dll" /R:"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ba060265\c782e097\assembly\dl3\23a0f85c\c6860362_a20fd001\Microsoft.Owin.Security.Cookies.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll" /R:"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ba060265\c782e097\assembly\dl3\dd63b6af\324e3162_a20fd001\Microsoft.Owin.Security.MicrosoftAccount.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Runtime.Serialization\v4.0_4.0.0.0__b77a5c561934e089\System.Runtime.Serialization.dll" /R:"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ba060265\c782e097\assembly\dl3\8758a470\fb8a665f_a20fd001\System.Web.WebPages.Razor.dll" /R:"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ba060265\c782e097\assembly\dl3\c1593243\2efaf384_a20fd001\PSC.dll" /R:"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ba060265\c782e097\assembly\dl3\65032d90\c0c11f62_a20fd001\Microsoft.Owin.Security.Twitter.dll" /R:"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ba060265\c782e097\assembly\dl3\f16b7dc5\a8c7655f_a20fd001\System.Web.WebPages.dll" /R:"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ba060265\c782e097\assembly\dl3\27062894\43e2d761_a20fd001\Owin.dll" /R:"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ba060265\c782e097\assembly\dl3\b63b4f1d\5870fb61_a20fd001\Microsoft.Owin.Security.Facebook.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_64\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Activities\v4.0_4.0.0.0__31bf3856ad364e35\System.Activities.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.Web.Infrastructure\v4.0_1.0.0.0__31bf3856ad364e35\Microsoft.Web.Infrastructure.dll" /out:"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ba060265\c782e097\App_global.asax.4djsb5yz.dll" /D:DEBUG /debug+ /optimize- /w:4 /nowarn:1659;1699;1701;612;618 /warnaserror- "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ba060265\c782e097\App_global.asax.4djsb5yz.0.cs" "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ba060265\c782e097\App_global.asax.4djsb5yz.1.cs" Microsoft(R) Visual C# 编译器版本 4.0.30319.19408 用于 Microsoft(R) .NET Framework 4.5 版权所有 (C) Microsoft Corporation。保留所有权利。 error CS0016: 未能写入输出文件“c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\ba060265\c782e097\App_global.asax.4djsb5yz.dll”--“拒绝访问。 ” |
产生原因:
应用程序运行时产生的临时文件需要存放到c:"windows"temp 文件夹下 而运行基于microsoft .net framework 框架下的应用程序 需要对temp 具有读写的权限 ,所以程序运行产生的临时文件不能存储或读取 ,或者路径不存在的情况下都会产生编译错误。
解决方法:
1、设置C:windows\temp 目录访问权限 temp--> 属性-->安全-- > 添加了iis_user和network service -->都赋予其权限为 读 和 写--> 确定
2、先关闭iis,清空 C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\ 目录(根据当前项目的Framework版本,文件夹可能有所不同),再重启IIS,然后给C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\目录(根据当前项目的Framework版本,文件夹可能有所不同)增加network service和了iis_user用户权限,并设置为读取和写入权限,添加方法见第1步。
3、给网站文件目录添加users和network service用户权限,并设置权限为读取和运行,添加方法见第1步。
在iis7下比较常见此问题,一般按以上步骤操作后即可解决,如果还不行,可给上面几个目录增加everyone和aspnet的权限测试一下。