Solve CS0016: Could not write to output file--Access is denied

Lionsure 2020-08-15 Original by the website

Generally speaking, after configuring website server permissions, the error "CS0016: Could not write to output file is denied access--Access is denied" is easy to appear in .net. The error prompts 'c:\windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\9218c35c\1d16c6e1\App_Web_index.aspx.29631bad.galqkak3.dll' -- 'Access is denied'. It is easy to mislead people, thinking that there is no permission to access the App_Web_index.aspx.29631bad.galqkak3.dll file, or no permission to modify a folder in the path. In fact, it has nothing to do with them. It Will be explainedc in the follow-up solution.

 

When opening the web page, the error details are as follows:

Server Error in '/' Application.
--------------------------------------------------------------------------------

Compilation Error 
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 

Compiler Error Message: CS0016: Could not write to output file 'c:\windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\9218c35c\1d16c6e1\App_Web_index.aspx.29631bad.galqkak3.dll' -- 'Access is denied'

Source Error:

[No relevant source lines]

Source File:    Line: 0 

Show Detailed Compiler Output:

c:\windows\system32\inetsrv> "c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\csc.exe" /t:library /utf8output /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Web.Entity\v4.0_4.0.0.0__b77a5c561934e089\System.Web.Entity.dll" /R:"c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\9218c35c\1d16c6e1\App_Web_0jjkjmza.dll" /R:"c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\mscorlib.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\assembly\GAC_MSIL\System.Runtime.Serialization\v4.0_4.0.0.0__b77a5c561934e089\System.Runtime.Serialization.dll" /R:"c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\9218c35c\1d16c6e1\assembly\dl3\f2beb448\2c3ef87b_e786cf01\LS.BLL.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_32\System.Web\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Web.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.ServiceModel\v4.0_4.0.0.0__b77a5c561934e089\System.ServiceModel.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\assembly\GAC_MSIL\System.ServiceModel.Web\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Web.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_32\System.EnterpriseServices\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll" /R:"c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\9218c35c\1d16c6e1\assembly\dl3\67b9a1d4\1c3bcb6a_9bc0c901\AjaxPro.2.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.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll" /R:"c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\9218c35c\1d16c6e1\assembly\dl3\d9cbb93b\18c98e91_e786cf01\LS.IDAL.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\Framework\v4.0.30319\Temporary ASP.NET Files\root\9218c35c\1d16c6e1\assembly\dl3\6bcd136a\be28daea_89decd01\LS.Config.dll" /R:"c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\9218c35c\1d16c6e1\assembly\dl3\8485848d\742437eb_89decd01\LS.Security.dll" /R:"c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\9218c35c\1d16c6e1\assembly\dl3\95328fc3\60b7e24f_4cedcd01\LS.Upload.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\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll" /R:"c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\9218c35c\1d16c6e1\assembly\dl3\8ce6408c\da9062d9_9c0ecf01\RL.WebUtility.dll" /R:"c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\9218c35c\1d16c6e1\assembly\dl3\d5633e77\f69d1e4f_4cedcd01\LS.Model.dll" /R:"c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\9218c35c\1d16c6e1\assembly\dl3\0dde29c3\c0aec784_e786cf01\LS.SQLServer.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.Web.ApplicationServices\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.ApplicationServices.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.Activation\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Activation.dll" /R:"c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\9218c35c\1d16c6e1\assembly\dl3\4cb66e2c\542973b4_4fedcd01\LS.DALFactory.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\Framework\v4.0.30319\Temporary ASP.NET Files\root\9218c35c\1d16c6e1\assembly\dl3\49a3cbe2\c6968ec0_c5e9cd01\LS.DBUtility.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_32\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll" /R:"c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\9218c35c\1d16c6e1\assembly\dl3\80e9a907\566abe0d_998bcf01\lisiya.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\assembly\GAC_MSIL\System.Xml.Linq\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.Linq.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\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll" /out:"c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\9218c35c\1d16c6e1\App_Web_index.aspx.29631bad.galqkak3.dll" /debug- /optimize+ /win32res:"c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\9218c35c\1d16c6e1\2rks2zkn.res" /w:4 /nowarn:1659;1699;1701 /warnaserror-  "c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\9218c35c\1d16c6e1\App_Web_index.aspx.29631bad.galqkak3.0.cs" "c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\9218c35c\1d16c6e1\App_Web_index.aspx.29631bad.galqkak3.1.cs"

Microsoft (R) Visual C# 2010 Compiler version 4.0.30319.1
Copyright (C) Microsoft Corporation. All rights reserved.

error CS0016: Could not write to output file 'c:\windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\9218c35c\1d16c6e1\App_Web_index.aspx.29631bad.galqkak3.dll' -- 'Access is denied'

 
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1022 

 

 

Solution:

1. Reason for the error: Users does not have permission to modify the temp folder in the C:\Windows directory. When .net needs to write temporary files to the temp folder, an exception occurs because of no permission to write.

 

2. Solution:

Just add the Users to the temp folder under the C:\Windows directory and assign the "Modify" permission; if the temp folder already has a Users, check the "Modify" permission. Methods as below:

A. right-click the temp folder, select "Properties" → "Security" tab → edit, as shown in Figure 1:

CS0016: Could not write to output file--Access is denied

Figure 1

 

B. Select the Users, check "Modify", and click "OK".

C. If the Users is not in the "group or user name", click "Add" → Advanced → Find Now → double-click the Users in the "Search Results" → OK.