Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  "BadImageFormatException" when trying to call cplex from .net web app

    Posted 04/02/13 05:03 AM

    Originally posted by: SystemAdmin


    Hi,
    I’m currently trying to use Cplex with C# in a .net web application, but I have problem when trying to lunch the application, apparently, cplex dlls are compiled in 32bits and my application is running on 64bits, I tried to force the application to run on x86 and I also enable 32bit applications in IIS, but the problem still appear every time.

    This is the exception:
    "System.BadImageFormatException: tentative de chargement d’un programme de format incorrect (Exception de HRESULT: 0x8007000B)"

    Is there any solution for my problem??
    I will appreciate your help, thank you.
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: "BadImageFormatException" when trying to call cplex from .net web app

    Posted 04/02/13 12:03 PM
    Hi,

    which version are you using?
    Maybe you are using a 32 bits CPLEX version and you need a 64 bits.

    regards
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: "BadImageFormatException" when trying to call cplex from .net web app

    Posted 05/24/18 01:02 PM

    Originally posted by: BMPG


    Hi,

     

    I see this question is quite old - but I'm running into the exact same issue despite running the x64 bit. My application is fully 64bit, and I am running the 64 bit trial version of CPLEX. It actually works when running as a console application, but as soon as it's in any sort of web app, I get the BadImageFormatException. I've gone through IIS to double check everything is 64 bit (even went down a route of tweaking my application to allow 32 bit version) but have had no success. We want to integrate CPLEX into a current C#.net web app environment, which in theory looks simple - but this run time error has us scratching our heads. 

     

    I am using the CPLEX Studio Community 12.8 Trial version. I am curious, is this just an issue with the trial version, or has any other fix/work around been found - I saw another instance of this question that trailed off, but no other solutions. Any assistance would be appreciated!

     

    v/r


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: "BadImageFormatException" when trying to call cplex from .net web app

    Posted 05/24/18 05:42 PM

    If you do a Google search for "BadImageFormatException IIS 64 bit" you'll see many issues specific to the way IIS is set up and different ways to fix them. To rule CPLEX out of the equation, have you tried creating a dummy 64-bit app (with no CPLEX in it) to see if that works in IIS? Have you made sure that the binaries you are working with really are 64 bit (e.g., checked with dumpbin.exe /headers as described here)?


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: "BadImageFormatException" when trying to call cplex from .net web app

    Posted 05/24/18 08:04 PM

    Originally posted by: BMPG


    Actually yes - while I'm in this trial phase I just created an isolated test web app to demonstrate internally CPlex's functionality to our team with a simple web GUI. I'm using a straight created no other dependency 64 bit web app. This is working fine - it only has had an issue when instantiating the CPlex object during runtime with code similar to the C# examples. I've made sure the references follow other tutorials and the examples, and it looks like it should be as simple as referencing the dll (if I did miss something, I'd be happy to try anything there!)

     

    I also spent some time tweaking/verifying IIS was in 64 bit, the build of the project, etc, every combination in 64bit, 32 bit, the IIS setting to allow 32 bit to run, etc - only to get the same error.

     

    I saw this thread and another which made our team go 'aha, we're not alone' so fingers crossed we find some insight here..!

    Thanks for the time!

    v/r


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 6.  Re: "BadImageFormatException" when trying to call cplex from .net web app

    Posted 05/25/18 04:23 AM

    Can you check with IIS people/support/forums if they have any suggestions how to debug this?

    Problem is that we are not exactly IIS experts and so far we have seen this exception only for 32bit/64bit mismatches which it seems you have already ruled out. Maybe IIS people can suggest other reasons that may trigger that exception. Or can at least tell a way to make extra sure things are set up properly.

    Could it be that IIS has loaded/cached the 32bit version of the library for another application and then is using that for your application as well? (this may be complete nonsense, but like I said, I am no expert in IIS)


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 7.  Re: "BadImageFormatException" when trying to call cplex from .net web app

    Posted 05/25/18 09:16 AM

    Originally posted by: BMPG


    Will do - thanks! At least this confirms its it doesn't sound like an issue specific to the trial, and that the expected behavior is to work even in a web environment. 

    v/r


    #DecisionOptimization
    #OPLusingCPLEXOptimizer