.NET 4.5 BadImageFormatException running in 64-bit process

499 views
Skip to first unread message

Michael Powell

unread,
Nov 12, 2014, 7:13:02 PM11/12/14
to or-tools...@googlegroups.com
Hello,

I have one test solution, pretty simple, that is 64-bit, actually targeting Any CPU, and OR works well.

However, in a broader scope, more robust application, I have a "problem solver" adapter to "hide the solver" from the rest of the way. Compilation works to a point, but still the OR DLL reference propagates more than I'd like. Well enough up to now.

When I run the test cases for this, I get BadImageFormatException loading the DLL. The DLL itself is there; gets pulled along with a 'Constraints' assembly providing the adapter.

Worst case I suppose I integrate the OR project from source instead of binaries, but I'd like to avoid that on account of additional dependencies, i.e. SWIG, etc.

Exception details below:

System.BadImageFormatException occurred
  HResult=-2147024885
  Message=Could not load file or assembly 'Google.OrTools, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.
  Source=
  FileName=Google.OrTools, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
  FusionLog==== Pre-bind state information ===
LOG: DisplayName = Google.OrTools, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
 (Fully-specified)
LOG: Appbase = /bin/Debug/
LOG: Initial PrivatePath = NULL
Calling assembly : , Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: \bin\Debug\Football.Migrator.vshost.exe.config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL /bin/Debug/Google.OrTools.DLL.
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.

  StackTrace:
       at Engine.Providers.DraftProvider.Populate(TeamCollection collection, Draft draft)
       at Migrator.Program.<>c__DisplayClass23.<Main>b__20(IUnitOfWork w, IRepository r) in \Program.cs:line 188
  InnerException:

Best regards,

Michael Powell

Michael Powell

unread,
Nov 13, 2014, 4:55:16 PM11/13/14
to or-tools...@googlegroups.com


On Wednesday, November 12, 2014 6:13:02 PM UTC-6, Michael Powell wrote:
Hello,

I have one test solution, pretty simple, that is 64-bit, actually targeting Any CPU, and OR works well.

However, in a broader scope, more robust application, I have a "problem solver" adapter to "hide the solver" from the rest of the way. Compilation works to a point, but still the OR DLL reference propagates more than I'd like. Well enough up to now.

When I run the test cases for this, I get BadImageFormatException loading the DLL. The DLL itself is there; gets pulled along with a 'Constraints' assembly providing the adapter.

After doing some digging, I soon discovered it was the database migration library I had adopted. Instead of mucking with those issues, I ended up rolling my own 64-bit, database migrator.

Not germane to OR, per se, but in the process I learned more and have a greater appreciation for some of the things Entity Framework (v6) offers. Especially after having been a long time die hard (Fluent) (N)Hibernate guy.

Migration works beautifully, then I can start to debug the OR model test cases.
 
Reply all
Reply to author
Forward
0 new messages