How to debug a 0x8007000B exception?

0

We have a C# application, that is compiled as a AnyCPU. This application uses an external library(which is also a .Net DLL on AnyCPU) that loads some C++ libraries in externals DLL.

Thoses externals libraries are either for X86, either for X64. We have a postbuild event that copies the one from X64 into the output folder.

We had everything working since years, and we have a lot of unit tests using this library.

Recently, on one computer(the build machine), the UnitTests now fails, with the following call stack.

The type initializer for 'Dew.Math.Units.MtxParseClass' threw an exception.
   at System.Runtime.CompilerServices.RuntimeHelpers._RunClassConstructor(RuntimeType type)
   at System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor(RuntimeTypeHandle type)
   at Dew.Math.TExprContext..cctor()

The type initializer for 'Dew.Math.Units.MtxVec' threw an exception.
   at System.Runtime.CompilerServices.RuntimeHelpers._RunClassConstructor(RuntimeType type)
   at System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor(RuntimeTypeHandle type)
   at Dew.Math.Units.MtxParseClass..cctor()

An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
   at Dew.Math.Units.Nmkl.kmp_set_blocktime(Int32 Value)
   at Dew.Math.TMtxVecController..ctor()
   at Dew.Math.Units.MtxVec.InitializeMtxVec()
   at Dew.Math.Units.MtxVec.Dew.Math.MtxVec()
   at Dew.Math.Units.MtxVec..cctor()

We have verified the C++ DLL are in 64 bits, our application is in AnyCPU on a 64 bits computers, so normally we should not have thoses errors.

The weird part is that: We didn't touch anything to thoses tests or on the tested classes, the tests still works fine on all other computers.

So my question:

How to debug it:

  • How to know the exact path of the DLL that fails being loaded
  • How to be sure that we are executed in X64 and not x86?
  • Any other idea to help me troubleshot this issue?
c#
.net
debugging
dllimport
asked on Stack Overflow Sep 6, 2017 by J4N

1 Answer

0

Note that using AnyCPU on x64 prefers 32bit. You can change this in the build settings for the project

answered on Stack Overflow Sep 6, 2017 by Tom Schardt

User contributions licensed under CC BY-SA 3.0