我们有一个C#应用程序,编译为AnyCPU
。 此应用程序使用外部库(它也是AnyCPU上的.Net DLL),它在外部DLL中加载一些C++库。如何调试0x8007000B异常?
Thoses externals库是用于X86,或者用于X64。我们有一个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,所以通常我们不应该放入系统错误。
奇怪的是:我们没有碰到任何测试或测试类,测试在所有其他计算机上仍能正常工作。
所以我的问题:
如何调试它:
- 如何知道
- 如何确保我们在X64执行失败正在加载的DLL的确切路径不是x86?
- 任何其他想法来帮助我解决这个问题?
总是这是32/64位不匹配。如果你的DLL是64位,那么你的.net代码应该是64位而不是AnyCPU。 –
@DavidHeffernan 1)我知道这是一个32/64不匹配,我想弄清楚为什么。 2)我不同意。创建AnyCPU DLL将允许您使用由64或32位可执行的此DLL。您提到的问题并没有提供关于如何查找外部库加载哪个DLL的提示。 – J4N
因此,当你将目标改为64位时,你观察到同样的故障? –