{channel.title!channel.name} - 楚淮公司周东林

试图加载格式不正确的程序

IIS在部署项目的时候提示试图加载不正确的程序,这个问题很容易忽略,程序池的需要启用 32 位应用程序支持。


下面是报错信息:

Server Error in '/' Application.


Could not load file or assembly 'wsxf' or one of its dependencies. 试图加载格式不正确的程序。

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: Could not load file or assembly 'wsxf' or one of its dependencies. 试图加载格式不正确的程序。

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.


Assembly Load Trace: The following information can be helpful to determine why the assembly 'wsxf' could not be loaded.

 

 

 

 

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].


Stack Trace:

 

 

 

 

[BadImageFormatException: Could not load file or assembly 'wsxf' or one of its dependencies. 试图加载格式不正确的程序。]
   System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
   System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks) +567
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +192
   System.Reflection.Assembly.Load(String assemblyString) +35
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +118

[ConfigurationErrorsException: Could not load file or assembly 'wsxf' or one of its dependencies. 试图加载格式不正确的程序。]
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +11392147
   System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +484
   System.Web.Configuration.AssemblyInfo.get_AssemblyInternal() +127
   System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +334
   System.Web.Compilation.BuildManager.CallPreStartInitMethods() +280
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +1087

[HttpException (0x80004005): Could not load file or assembly 'wsxf' or one of its dependencies. 试图加载格式不正确的程序。]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +11524352
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +141
   System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +11356670

解决方法:

到 IIS 信息服务管理器里面,找到"应用程序池"可能有多个,点击程序使用的应用应用程序池,右侧菜单“高级设置”,在弹出的高级设置菜单里"启用 32 位应用程序" 选项选择 true.