col403
col403

Reputation: 41

BadImageFormatException when deploying on windows server 2012 r2

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.

Upvotes: 3

Views: 900

Answers (2)

col403
col403

Reputation: 41

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.

Upvotes: 1

user326608
user326608

Reputation: 2548

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.

Upvotes: 0

Related Questions