情景:当我们用VS2005开发一个web程序时,在WIN2003或WIN2008的32位操作系统上运行正常时,而部署到win2008 R2的64位操作系统(注:目前win2008 R2只有64位操作系统)出错。

情景:当我们用VS2005开发一个web程序时,在WIN2003或WIN2008的32位操作系统上运行正常时,而部署到win2008 R2的64位操作系统(注:目前win2008 R2只有64位操作系统)出现
Server Error in '/CMISWebAdminDevelopment' Application.
is not a valid Win32 application. (Exception from HRESULT: 0x800700C1)
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.BadImageFormatException: is not a valid Win32 application. (Exception from HRESULT: 0x800700C1)
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. |
Stack Trace:
[BadImageFormatException: is not a valid Win32 application. (Exception from HRESULT: 0x800700C1)] System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +0 System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +495 System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +192 System.Reflection.Assembly.Load(String assemblyString) +42 System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +182
[ConfigurationErrorsException: is not a valid Win32 application. (Exception from HRESULT: 0x800700C1)] System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +1259 System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +388 System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +145 System.Web.Configuration.AssemblyInfo.get_AssemblyInternal() +30 System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +227 System.Web.Compilation.BuildProvidersCompiler..ctor(VirtualPath configPath, Boolean supportLocalization, String outputAssemblyName) +76 System.Web.Compilation.CodeDirectoryCompiler.GetCodeDirectoryAssembly(VirtualPath virtualDir, CodeDirectoryType dirType, String assemblyName, StringSet excludedSubdirectories, Boolean isDirectoryAllowed) +856 System.Web.Compilation.BuildManager.CompileCodeDirectory(VirtualPath virtualDir, CodeDirectoryType dirType, String assemblyName, StringSet excludedSubdirectories) +239 System.Web.Compilation.BuildManager.CompileCodeDirectories() +599 System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +767
[HttpException (0x80004005): is not a valid Win32 application. (Exception from HRESULT: 0x800700C1)] System.Web.Compilation.BuildManager.ReportTopLevelCompilationException() +76 System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +1168 System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters) +906
[HttpException (0x80004005): is not a valid Win32 application. (Exception from HRESULT: 0x800700C1)] System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +709 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +317 System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +595
|
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42

solve method 如下:
1. Inside IIS (7) click on Application Pools.
2. Find the Application Pool that is configured for your web application in the list.
3. Select it, then click Advanced Settings on the right.
4. Second setting in the list: Enable 32-Bit Applications - must be set to True.
5.identity -should be set to localsystem

注:操作系统是英文版,所以大部分是英文信息。