这个错误令我非常沮丧,我无法在网上找到任何内容。
我有一个MITab V1.7.0 dll和一个包含以下内容的MiApi.cs文件:
// $Id: MiApi.cs,v 1.2 2005/03/24 17:02:06 dmorissette Exp $
//
using System;
using System.Runtime.InteropServices;
using System.IO;
using System.Collections;
namespace EBop.MapObjects.MapInfo {
/// <summary>
/// Wrapper functions for the version 1.3.0 of the MapInfo Tab API.
/// </summary>
/// <remarks>
/// Requires MITab.dll (www.maptools.org)
/// See http://mitab.maptools.org/
///
/// Graham Sims
/// Environment Bay of Plenty, Whakatane, New Zealand
/// http://www.envbop.govt.nz
/// </remarks>
public class MiApi {
// -- enums left out for brevity //
private MiApi() {
}
/// <summary>
/// Returns the version of the library.
/// </summary>
/// <returns>An integer representing the current version of the MITAB library in the
/// format xxxyyyzzz, e.g. returns 1002004 for v1.2.4.
/// </returns>
[DllImport("mitab.dll")]
public static extern int mitab_c_getlibversion();
// -- Other entry points -- //
}
}
当我尝试使用;
访问它时int version = MiApi.mitab_c_getlibversion();
我明白了;
A first chance exception of type 'System.BadImageFormatException' occurred in BBX.IAP.MapInfoProcessor.exe
Additional information: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
标准响应是我在64位应用程序中加载32位库或在32位中加载64位,但我已在两者中重新编译,并重新编译库。我还检查了符号并使用cdb来检查库的访问方式,但是我无法从输出中理解。
214c:2f54 @ -2131284890 - LdrLoadDll - ENTER: DLL name: C:\Users\Owen\X\deps\Debug\MITab.dll
214c:2f54 @ -2131284890 - LdrpLoadDll - ENTER: DLL name: C:\Users\Owen\X\deps\Debug\MITab.dll
214c:2f54 @ -2131284890 - LdrpLoadDll - INFO: Loading DLL C:\Users\Owen\X\deps\Debug\MITab.dll
214c:2f54 @ -2131284890 - LdrpFindOrMapDll - ENTER: DLL name: C:\Users\Owen\X\deps\Debug\MITab.dll
214c:2f54 @ -2131284890 - LdrpResolveDllName - ENTER: DLL name: C:\Users\Owen\X\deps\Debug\MITab.dll
214c:2f54 @ -2131284890 - LdrpResolveDllName - RETURN: Status: 0x00000000
214c:2f54 @ -2131284890 - LdrpMapViewOfSection - ENTER: DLL name: C:\Users\Owen\X\deps\Debug\MITab.dll
ModLoad: 00000000`1b680000 00000000`1b813000 C:\Users\Owen\X\deps\Debug\MITab.dll
214c:2f54 @ -2131284890 - LdrpMapViewOfSection - RETURN: Status: 0x4000000e
214c:2f54 @ -2131284890 - LdrpFindOrMapDll - RETURN: Status: 0xc000007b
214c:2f54 @ -2131284890 - LdrpLoadDll - RETURN: Status: 0xc000007b
214c:2f54 @ -2131284890 - LdrLoadDll - RETURN: Status: 0xc000007b
214c:2f54 @ -2131284890 - LdrLoadDll - ENTER: DLL name: MITab.dll
214c:2f54 @ -2131284890 - LdrpLoadDll - ENTER: DLL name: MITab.dll
214c:2f54 @ -2131284890 - LdrpLoadDll - INFO: Loading DLL MITab.dll
214c:2f54 @ -2131284890 - LdrpFindOrMapDll - ENTER: DLL name: MITab.dll
214c:2f54 @ -2131284890 - LdrpFindKnownDll - ENTER: DLL name: MITab.dll
214c:2f54 @ -2131284890 - LdrpFindKnownDll - RETURN: Status: 0xc0000135
214c:2f54 @ -2131284890 - LdrpSearchPath - ENTER: DLL name: MITab.dll
我甚至确认使用dumpbin
中的符号存在于dll中1610 649 000015E1 _mitab_c_getlibversion@0 = @ILT+1500(_mitab_c_getlibversion@0)
最糟糕的是,我从该程序输出,表明它过去已成功运作。我所留下的只是沮丧和困惑。
任何人都能告诉我我的错误吗?
答案 0 :(得分:1)
好了...
虽然我发誓我已经确定它们都是x64 ......我错了。
MiTab.dll是一个旧库,它被设置为Win32。我不得不深入了解编译指令,找到它设置为Win32的位置并进行更改。错误立即消失了。
课程:即使您的所有设置都说代码是以Win32或x64生成的,请检查它。