Wednesday, June 11, 2008

Fixing the: System.InvalidOperationException: Unable to generate a temporary class : Error

More testing on our new Application Server and I encountered the error

System.InvalidOperationException: Unable to generate a temporary class(result=1). error CS2001: Source file ...

Unfortunately Microsoft offers this advice:
"To avoid this problem, give read/write priviledges for the Temp folder to the ASPNET account"

While technically correct, this treating the symtom instead of the root cause.
Chances are if the ASPNET account does not have one permission it needs, then there are other permission missing. These accounts and permissions are usually missing because IIS is installed after the Dot Net Framework.

When the Framework is installed after IIS, it detects the existence of IIS and configures the appropriate accounts.

To do this manually you need to run the following command:
aspnet_regiis.exe -i

This registers aspnet with IIS. The side effect is all the appropriate account are created.

No comments: