我們有一個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位時,你觀察到同樣的故障? –