如何调试0x8007000B异常?

时间:2017-09-06 11:03:50

标签: c# .net debugging dllimport

我们有一个C#应用程序,编译为AnyCPU。 此应用程序使用外部库(也是AnyCPU上的.Net DLL),在外部DLL中加载一些C ++库。

对于X64,要么是外部库,要么是X86。我们有一个postbuild事件,将X64中的那个复制到输出文件夹中。

我们已经有了多年的工作,我们使用这个库进行了大量的单元测试。

最近,在一台计算机(构建机器)上,UnitTests现在失败,并带有以下调用堆栈。

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()

我们已经验证了C ++ DLL是64位的,我们的应用程序是在64位计算机上的AnyCPU中,所以通常我们不应该有错误。

奇怪的是:我们没有接触到测试或测试类的任何内容,测试仍可在所有其他计算机上正常工作。

所以我的问题:

如何调试:

  • 如何知道未加载的DLL的确切路径
  • 如何确保我们在X64而不是x86中执行?
  • 任何其他想法可以帮助我解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

请注意,在x64上使用AnyCPU更喜欢32位。您可以在项目的构建设置中更改此项

相关问题