Error message when ASP.NET 2.0 is configured to run with a user account: "Unable to generate a temporary class" (908158)



The information in this article applies to:

  • Microsoft .NET Framework 2.0

SYMPTOMS

Consider the following scenario:
  • You create a Microsoft ASP.NET 2.0 application.
  • ASP.NET 2.0 is configured to run with a user account.
  • The SerializeAs attribute of the Profile property in ASP.NET 2.0 is set to Xml.
In this scenario, ASP.NET 2.0 may not save the user profile, and you may receive an error message that is similar to the following:
[InvalidOperationException: Unable to generate a temporary class (result=1).
error CS2001: Source file 'D:\WINDOWS\TEMP\d0lurtzx.0.cs' could not be found
error CS2008: No inputs specified

CAUSE

This issue occurs if the user account does not have the List Folder Contents and Read permissions on the %windir%\Temp folder.

RESOLUTION

To resolve this issue, grant the user account the List Folder Contents and Read permissions on the %windir%\Temp folder.

MORE INFORMATION

Steps to reproduce the issue

  1. Create a Web site in Microsoft Internet Information Services (IIS) Manager.
  2. Create a local Microsoft Windows NT user account.
  3. Click Start, click Run, type cmd, and then click OK.
  4. At the command prompt, type the following command:

    cd Path

    Note Path represents the path of the Microsoft .NET Framework 2.0 folder on the computer.
  5. At the command prompt, type the following command, and then press ENTER:

    aspnet_regiis -ga User

    Note User represents the user account that you created in step 2.
  6. Change the application pool identity for the Web site that you created in step 1 to the account that you created in step 2.
  7. Click Start, click Run, type cmd, and then click OK.
  8. At the command prompt, type iisreset /restart, and then press ENTER.
  9. Create a Web.config file, and then add the following code example to the Web.config file.

    Note <Server> represents the name of the server, <User> represents the user name, <Password> represents the password for the user, and <Catalog> represents the catalog name.
    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <system.web>
        <customErrors mode="Off" />
        <profile defaultProvider="SqlPProvider" enabled="true">
          <providers>
            <add name="SqlPProvider" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=1.2.3400.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="SqlPProviderConnection" />
          </providers>
          <properties>
            <add name="FavoriteURLs" type="System.Collections.Specialized.StringCollection" readOnly="false" serializeAs="Xml" />
          </properties>
        </profile>
        <anonymousIdentification enabled="true" cookieless="UseDeviceProfile" />
        <authentication mode="Forms">
          <forms>
            <credentials passwordFormat="Clear">
              <user name="a" password="a" />
            </credentials>
          </forms>
        </authentication>
        <authorization>
          <deny users="?" />
        </authorization>
      </system.web>
      <connectionStrings>
        <add name="SqlPProviderConnection" connectionString="server=<Server> ;UID=<User>;PWD=<Password>;Initial Catalog=<Catalog>" />
      </connectionStrings>
    </configuration>
  10. Create a file that is named Login.aspx, and then add the following code example to the Login.aspx file.
    <%@ Page LANGUAGE="cs" %>
    <form runat=server>
    	<asp:literal runat=server id="MyText" Text=""></asp:literal>
    	<asp:TextBox runat=server id="UsernameTextBox" Text="Type a user name"></asp:TextBox>
    	<asp:TextBox runat=server id="PasswordTextBox" Text="Type a password"></asp:TextBox>
    	<asp:Button id="Submit"  Text="Submit" runat="server"/>
    </form>
    <script runat="server" >
    protected void Page_Load(Object source, EventArgs e)
      {
    	
    	MyText.Text += "[Login Page: you are not authenticated]<br>";
          String strUserName  = UsernameTextBox.Text;
          String strPassword  = PasswordTextBox.Text;
    
          bool   fPersist     = false;
          bool   fVerifed     = System.Web.Security.FormsAuthentication.Authenticate(strUserName, strPassword);
          if( fVerifed)
          {
              System.Web.Security.FormsAuthentication.RedirectFromLoginPage(strUserName, fPersist);
          }
      }
    
    </script>
  11. Create a file that is named Test.aspx, and then add the following code example to the Test.aspx file.
    <%@ Page LANGUAGE="cs" Debug="true" %>
    <form runat="server">
    	<asp:Literal runat="server" id="Literal1" Text=""></asp:literal>
    	<asp:Button text="Signout" OnClick="Signout_Click" id="SignOutButton" runat=server/>
    </form>
    <script runat="server" >
    void Page_Load(object sender, EventArgs e) 
    {
    
    	Literal1.Text += "[User.Identity.Name=" + User.Identity.Name +"]<br>";
    	Profile.FavoriteURLs = new System.Collections.Specialized.StringCollection();
    	Profile.FavoriteURLs.Add("MyString1");
    	Profile.FavoriteURLs.Add("MyString2");
    	Profile.FavoriteURLs.Add("MyString3");
    
    
    	if (Profile.FavoriteURLs != null) {
    		for (int i=0; i<Profile.FavoriteURLs.Count; i++) {
    			Literal1.Text += "[FavoriteURLs=" + Profile.FavoriteURLs[i] + "]<br>";
    		}
    	}
    	
    }
    
    
    void Signout_Click(Object sender, EventArgs E) {  
        System.Web.Security.FormsAuthentication.SignOut();
        Response.Redirect(System.Web.Security.FormsAuthentication.LoginUrl);
    }
    </script>
  12. Request Test.aspx.

Modification Type:MajorLast Reviewed:1/23/2006
Keywords:kbtshoot kberrmsg kbcode kbprb KB908158 kbAudDeveloper