<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>bloggo ergo sum &#187; ASP.NET</title>
	<atom:link href="http://bloggoergosum.com/tag/asp-net/feed/" rel="self" type="application/rss+xml" />
	<link>http://bloggoergosum.com</link>
	<description></description>
	<lastBuildDate>Thu, 15 Mar 2012 05:47:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>ASP.NET CS0016 &#8211; Compiler Access Denied</title>
		<link>http://bloggoergosum.com/2011/07/28/asp-net-cs0016-compiler-access-denied/</link>
		<comments>http://bloggoergosum.com/2011/07/28/asp-net-cs0016-compiler-access-denied/#comments</comments>
		<pubDate>Thu, 28 Jul 2011 07:34:22 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://bloggoergosum.com/?p=550</guid>
		<description><![CDATA[Once in a while, a developer will have one of those unbelievably frustrating problems with his environment or platform that makes him bang his head against the wall for hours.  I&#8217;m sure people in other trades have similar experiences somehow, but I don&#8217;t know of a good parallel offhand. I just experienced such a problem <a href="http://bloggoergosum.com/2011/07/28/asp-net-cs0016-compiler-access-denied/"> read more <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Once in a while, a developer will have one of those unbelievably frustrating problems with his environment or platform that makes him bang his head against the wall for hours.  I&#8217;m sure people in other trades have similar experiences somehow, but I don&#8217;t know of a good parallel offhand.</p>
<p>I just experienced such a problem with ASP.NET.  I just imported a deployment package of a self-hosted NuGet feed, which is just an empty ASP.NET application built as explained in the<a title="Hosting your own NuGet feeds" href="http://docs.nuget.org/docs/creating-packages/hosting-your-own-nuget-feeds"> NuGet documentation</a>.  Anyway, after importing the deployment package using webdeploy (via the IIS Management Console), I had an application under my default web site called &#8220;nuget&#8221;.  After that, I kind of expected it to Just Work, at least from the server itself.</p>
<p><a href="http://bloggoergosum.com/wp-content/uploads/2011/07/Capture.png"><img class="size-full wp-image-551 alignleft" title="Capture" src="http://bloggoergosum.com/wp-content/uploads/2011/07/Capture.png" alt="" width="266" height="200" /></a> I opened Internet Explorer and navigated to http://localhost/nuget, and got the following nastiness:</p>
<blockquote><p><strong>Compiler Error Message: </strong>CS0016: Could not write to output file &#8216;c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\62d43c41\27d749ca\App_Code.7lodcznm.dll&#8217;</p></blockquote>
<p>The particular DLL the compiler was trying to write was different than shown, but this is the error.  Well, I found several posts just glibly saying &#8220;all you have to do is make sure the &#8216;Temporary ASP.NET Files&#8217; permissions are set properly&#8221;.  It sure sounded easy enough.  Turns out, it was too easy, because it didn&#8217;t work.  I ended up giving full control to &#8220;Everyone&#8221; to kind of prove what was really going on.  After that didn&#8217;t work, I ran procmon and filtered carefully to find a non-SUCCESS event on a path including &#8220;temp&#8221; and by a process called &#8220;csc.exe&#8221; (the C# compiler).  Sure enough, I found this:</p>
<blockquote>
<pre>3:01:01.3158251 AM	csc.exe	6428	CreateFile	C:\Windows\Temp\RES3277.tmp	ACCESS DENIED</pre>
<pre>Desired Access: Generic Read, Disposition: Create, Options: Synchronous IO Non-Alert, Non-Directory File,</pre>
<pre>Attributes: N, ShareMode: None, AllocationSize: 0</pre>
</blockquote>
<p>You can see here that the actual error is not what appeared in the browser window, frustratingly. I gave Full Control permissions to the Everyone group on \Windows\Temp, and that seemed to fix it.</p>
<p>Well, that won&#8217;t do &#8211; it&#8217;s not a good idea to do the equivalent of &#8220;chmod 777&#8243; on \Windows\Temp, so I needed to give access to just the DefaultAppPool user.  Well, guess what?  When I went through Explorer, I was not able to find the user through the UI to give it permissions.  Ultimately, I figured out that I could do it using icacls:</p>
<blockquote>
<pre>PS C:\Windows&gt; icacls Temp /t /grant "IIS AppPool\DefaultAppPool:(F)"</pre>
</blockquote>
<p>After doing the same to the &#8220;Temporary ASP.NET Files&#8221;  folder, I was done.  Finally.  Now I&#8217;ve got a 404 error to fix&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://bloggoergosum.com/2011/07/28/asp-net-cs0016-compiler-access-denied/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

