Error message when you try to run a Web application that is built on the .NET Framework 2.0: "Unable to cast object" (924731)



The information in this article applies to:

  • Microsoft .NET Framework 2.0

SYMPTOMS

When you try to run a Web application that is built on the Microsoft .NET Framework 2.0, you may receive an error message that resembles the following:
Server Error in '/appname' Application.

"Unable to cast object of type 'System.Web.Compilation.BuildResultCompiledAssembly' to type 'System.Web.Util.ITypedWebObjectFactory'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Unable to cast object of type 'System.Web.Compilation.BuildResultCompiledAssembly' to type 'System.Web.Util.ITypedWebObjectFactory'."
Note In this error message, appname is a placeholder for the name of the Web application.

This problem occurs after you restart the Web application.

Note This problem may continue to occur even after you use the iisreset command to reset Microsoft Internet Information Services (IIS).

CAUSE

This problem is caused when a satellite assembly that has a nonneutral culture is located directly in the Bin folder of the Web application. Satellite assemblies must be located in a subfolder of the Bin folder. Additionally, satellite assemblies must have a name that is equal to the culture of the assembly, such as en-GB.

RESOLUTION

To resolve this problem, move the satellite assembly that has a nonneutral culture to a subfolder of the Bin folder.

MORE INFORMATION

You can determine whether a satellite assembly has a nonneutral culture by considering the AssemblyCulture attribute of the assembly. For example, a satellite assembly that has a specific culture contains an AssemblyCulture attribute that resembles the following.
[assembly: AssemblyCulture("en-GB")]
A satellite assembly that has a neutral culture contains the following AssemblyCulture attribute.
[assembly: AssemblyCulture("")]

Modification Type:MajorLast Reviewed:9/12/2006
Keywords:kbtshoot kbinfo kbprb KB924731 kbAudDeveloper