Why is 32-bit-mode required in IIS7.5 for the app

.net-4.032bit-64bitiis-7

I have a .net4 web application running in a 64 bits 2008 server. I can only get it to run when I set the app pool to Enable 32-bits application to true. All dlls are compiled for .net4 (verified with corflags.exe). How can I figure out why Enable 32-bit is required?

The error message from the event log when starting as a 64-bit app-pool

Event code: 3008
Event message: A configuration error has occurred.
Event time: 2011-03-16 08:55:46
Event time (UTC): 2011-03-16 07:55:46
Event ID: 3c209480ff1c4495bede2e26924be46a
Event sequence: 1
Event occurrence: 1
Event detail code: 0

Application information:
Application domain: removed
Trust level: Full
Application Virtual Path: removed
Application Path: removed
Machine name: NMLABB-EXT01

Process information:
Process ID: 4324
Process name: w3wp.exe
Account name: removed

Exception information:
Exception type: ConfigurationErrorsException
Exception message: Could not load file or assembly 'System.Data' or one of its dependencies. An attempt was made to load a program with an incorrect format.
at System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective)
at System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory()
at System.Web.Configuration.AssemblyInfo.get_AssemblyInternal()
at System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig)
at System.Web.Compilation.BuildManager.CallPreStartInitMethods()
at System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException)

Could not load file or assembly 'System.Data' or one of its dependencies. An attempt was made to load a program with an incorrect format.
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.Load(String assemblyString)
at System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective)

Request information:
Request URL: "our url"
Request path: "url"
User host address: ip-adddress
User:
Is authenticated: False
Authentication Type:
Thread account name: "app-pool"

Thread information:
Thread ID: 6
Thread account name: "app-pool"
Is impersonating: False
Stack trace: at System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective)
at System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory()
at System.Web.Configuration.AssemblyInfo.get_AssemblyInternal()
at System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig)
at System.Web.Compilation.BuildManager.CallPreStartInitMethods()
at System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException)

Custom event details:

Best Answer

Most likely, because one or more of the components used by your application are 32-bit.

Or, because one or more components used by your application are not found when you toggle the App Pool mode, because of their bitness, and file system redirection.

Generally speaking, IIS will divide up Modules and Handlers into 32- and 64-bit binaries, and prevent one bitness or another from seeing the other bitness with the bitness32 or bitness64 preconditions.

Top-of-head example:

<modules> <module name="something" path="c:\program files\something.dll" precondition="bitness64"> </modules>

If you change the app pool to 32 bit, keep in mind:

  • bitness64 won't be true
  • 64 bit apps aren't lied to about file locations; 32 bit apps might be (Program Files (x86), or System32 (which redirects to SysWow64))

the same module/handler might have an entry like this:

<modules> <module name="something32" path="c:\program files\something32.dll" precondition="bitness32"> </modules>

Which will only work if something32.dll is in Program files (x86).

The event logs should help you track down which module is being problematic, if it's a module or handler load failure.

If your modules or handlers don't specify a bitness precondition, and might use different paths when run from a different bitness due to redirection, you've got your problem. (the event logs will typically point you at what failed to load when an App Pool won't start).

See also:

Related Topic