构造 System.Data.SQLite.SQLiteConnection 时是什么导致 System.BadImageFormatException [英] What causes System.BadImageFormatException when constructing System.Data.SQLite.SQLiteConnection

查看:23
本文介绍了构造 System.Data.SQLite.SQLiteConnection 时是什么导致 System.BadImageFormatException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将代码分解为尽可能最小的语句:

I've broken the code down to the smallest possible statement:

Dim cn As System.Data.SQLite.SQLiteConnection

从 WinForm 应用程序调用代码时出现以下错误:

And I get the following error when calling the code from a WinForm applicaiton:

System.BadImageFormatException:可以不加载文件或程序集'System.Data.SQLite,版本=1.0.65.0,文化=中立,PublicKeyToken=db937bc2d44ff139' 或它的依赖项之一.一次尝试被用来加载一个程序格式不正确.文档名称:'System.Data.SQLite,版本=1.0.65.0,文化=中立,PublicKeyToken=db937bc2d44ff139'

System.BadImageFormatException: Could not load file or assembly 'System.Data.SQLite, Version=1.0.65.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139' or one of its dependencies. An attempt was made to load a program with an incorrect format. File name: 'System.Data.SQLite, Version=1.0.65.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139'

然而从 MS 单元测试调用同一段代码我没有收到错误,加上完整的代码集按预期工作.

Yet calling the same piece of code from MS Unit Test I do not get the error, plus the full code set works as expected.

推荐答案

SQLite 包含非托管代码,除非部署 64 位版本,否则无法在 64 位操作系统上运行它.快速修复:项目 + 属性、构建选项卡、平台目标 = x86.

SQLite contains unmanaged code, you can't run it on a 64-bit operating system unless you deploy the 64-bit version. Quick fix: Project + Properties, Build tab, Platform Target = x86.

这篇关于构造 System.Data.SQLite.SQLiteConnection 时是什么导致 System.BadImageFormatException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆