BadImageFormatException when deploying on windows server 2012 r2

3

I am deploying my Asp.net application on Windows Server 2012 R2(x64). I get a runtime BadImageFormatException while using 64-bit dll. When I run it with IIS Express or application published on local machine IIS everything works well (Application pools -> solution name -> Enable 32-bit applications set to False, All projects in solution are also set for Platform target x64). Deploy is going through Team City & Octopus Deploy.

What the solution could be?

UPD System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B) at libxl.XmlBook.xlCreateXMLBookC() at xxx.Controllers.xxx.xxxController.LibxlTest() in C:\TeamCity\buildAgent\work\aeb63fe0b246a1f3\xxx\xxx\Controllers\xxx\xxx\xxxController.cs:line 597

There is no such path C:\TeamCity\buildAgent\ on server whrere the Octopus Tentacle is.

c#
asp.net
iis
dll
windows-server-2012-r2
asked on Stack Overflow Mar 13, 2017 by col403 • edited Apr 20, 2017 by col403

2 Answers

1

Finally, it works with x86 (from bin folder) version while the solution was build for x64. Probably, it is a peculiarity of libxl. Thus, I'm developing with x64 and after deploy my post-deploy script changes it for x86 version.

answered on Stack Overflow Apr 25, 2017 by col403
0

OK, it looks like you or one of your references has a dependency on libXL.

Your exception result (0x8007000B) is definitely a 32-bit can't load on 64-bit issue.

libXL is C++ project, in the download zip there's a bin64 folder with a copy of libxl.dll that will work in 64-bit mode.

If you have a libXL licensed copy better to use the 64-bit dll from that.

Note that C:\TeamCity\buildAgent\ comes from the machine your project was built on, the line numbers etc get saved into your pdb files.

answered on Stack Overflow Apr 22, 2017 by user326608

User contributions licensed under CC BY-SA 3.0