简体   繁体   English

从 .Net 连接到 DB2 时出现 System.BadImageFormatException

[英]System.BadImageFormatException while connecting to DB2 from .Net

I have DB2 server that I'm trying to connect from my machine, but I keep getting the below error when I start the application, before even start the connection我有 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. System.BadImageFormatException: '无法加载文件或程序集 'IBM.Data.DB2, Version=9.7.4.4, Culture=neutral, PublicKeyToken=7c307b91aa13d208' 或其依赖项之一。 An attempt was made to load a program with an incorrect format.'试图加载格式不正确的程序。

please not that I don't have DB2 driver installed on my machine.请注意,我的机器上没有安装 DB2 驱动程序。 but I refer to the below libraries in my application, which I got them from DB2 database server.但我在我的应用程序中引用了以下库,这些库是从 DB2 数据库服务器获取的。

  • IBM.Data.DB2; IBM.Data.DB2;
  • IBM.Data.DB2.Entity; IBM.Data.DB2.Entity;
  • IBM.Data.Informix; IBM.Data.Informix;

Normally the error message is caused by a 32/64 bit conflict.通常,错误消息是由 32/64 位冲突引起的。

Your program could be compiled in 64 bit (or any) and the drivers in 32 bit or the other way round.您的程序可以编译为 64 位(或任何),而驱动程序可以编译为 32 位或相反。

Check the Configuration Manager and set the Platform to x86 or x64.检查配置管理器并将平台设置为 x86 或 x64。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM