CS0016: Could not write to output file 'c:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/-- '拒绝访问'

CS0016: Could not write to output file 'c:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/-- '拒绝访问'

想到的第一个解决方法是,把备份的文件覆盖掉现在修改过后的文件,立即行动!可以解决,但是过了几分钟之后,问题还是存在,然后再覆盖就不好使了, 并且发现另外几个链接的文件都出现了这个问题,想了很多方法还是没有解决,参考网上大家的建议以及MSDN中找到的解决方法,终于找到了解决方法:

出现CS0016的原因一般是临时目录的权限不够,解决的办法是给Windows目录下的临时文件夹Temp的安全选项卡中加入NetWork Service用户并赋予全权。

记住,你最好重新启动一下计算机,因为我按照MSDN的执行之后发现问题依旧,最后看到了他们的notes,才重起电脑,问题解决!

MSDN的资料如下:http://support.microsoft.com/default.aspx?scid=kb;en-us;825791

SYMPTOMSWhen you view a Microsoft ASP.NET Application in a Web browser, you may receive the following error messages:

For the Microsoft .NET Framework version 1.1, the error message is the following:
CS0016: Could not write to output file 'c:/WINDOWS/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET Files/application1/c11b43f6/cf3ec03/rizcntet.dll' . The directory name is invalid.
For the .NET Framework 1.0, the error message is the following:
CS0013: Unexpected error writing metadata to file 'C:/WINDOWS/Microsoft.NET/Framework/v1.0.3705/Temporary ASP.NET Files/application2/3fc72f26/eb731247/ev2bslce.dll'. The directory name is invalid.

CAUSEThe system TEMP and TMP variables point to a folder that does not exist. The compiler generates temporary files in the folder where the TEMP and the TMP variables point to before the files are copied to the Temporary ASP.NET Files folder. However, the folder where the system variables point to is deleted when you restart the computer. Therefore, the compiler cannot generate the temporary files.

RESOLUTION1. Create a temporary folder under %Systemroot%, and then name it Temp. 
2. Grant full permissions on the Temp folder to the aspnet user account in .NET Framework 1.0 or to the NETWORK SERVICE user account in .NET Framework 1.1.
3. Right-click My Computer, and then click Properties.
4. On the Advanced tab, click Environment Variables.
5. Select the TEMP variable under System variables, and then click Edit.
6. Type %SystemRoot%/TEMP in the Variable Value box, and then click OK.
7. Repeat steps 5 and 6 to edit the TMP variable. Click OK two times.
8. Click Start, and then click Run. 
9. To reset Internet Information Services (IIS), type iisreset on the command prompt.

Note If the error message that is mentioned in the "Symptoms" section of this article persists, restart the computer


只是建议朋友试一下 将 Windows/Temp 的 Network Service 帐户赋予了完全控制的权限 ...
    
    可能会由于系统 TEMP 或 TMP 变量指向的文件夹不存在或者权限不足, 编译器生成的临时文件放在 TEMP 或 TMP 环境变量指向的文件夹, 然后复制到 Temporary ASP.NET Files 目录下.

    解决方案:
   
    1. 在 %Systemroot% 下创建一个目录, 命名为 Temp. (如果已经存在该目录, 此步可略过)
    2. 将该目录的 aspnet 用户帐户(相对于 .NET Framework 1.0 来说) 或者是 NETWORK SERVICE 用户帐户(相对于 .NET Framework 1.1 以上版本)赋予完全许可权限.
    3. 将系统环境变量 TEMP 指向 %SystemRoot%/TEMP .
    4. 将系统环境变量 TMP 指向 %SystemRoot%/TEMP .
    5. 如果有必要, 在开始——〉RUN 中输入 iisreset 重置 Internet Information Services (IIS).
    6. 如果有必要, 重启计算机.

posted @ 2012-03-23 10:47  dotNET界面-大白  阅读(2854)  评论(0编辑  收藏  举报