System.BadImageFormatException 从 .Net 连接到 DB2

System.BadImageFormatException while connecting to DB2 from .Net

我有 DB2 服务器,我正尝试从我的机​​器连接,但在启动应用程序时,甚至在启动连接之前,我一直收到以下错误

System.BadImageFormatException: 'Could not load file or assembly 'IBM.Data.DB2, Version=9.7.4.4, Culture=neutral, PublicKeyToken=7c307b91aa13d208' or one of its dependencies. An attempt was made to load a program with an incorrect format.'

请注意,我的机器上没有安装 DB2 驱动程序。但我在我的应用程序中引用了以下库,它们是从 DB2 数据库服务器获取的。

通常错误消息是由 32/64 位冲突引起的。

您的程序可以编译为 64 位(或任何),而驱动程序可以编译为 32 位,反之亦然。

检查配置管理器并将平台设置为 x86 或 x64。