当在IIS 中发布.net的web应用时,

出现错误:

Server Error in ‘/’ Application.

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

……

查找后判断是应用程序链接池 Application Pool调用的dll文件出现了错误,多是在于64位平台调用32位的dll引起的。

解决方式 : 找到发布的iis站点应用使用的应用程序池 Application Pool,点开高级设置->将”Enable 32-bit applications” 项目选择为true,兼容32位应用程序。