使用System.Data.SQLite打开conn时出错,尝试加载格式不正确的程序。 Interop.084

时间:2013-03-14 02:44:54

标签: c# sqlite system.data.sqlite

我是C#的新手,我正在尝试使用System.Data.SQLite建立数据库连接。我正在使用Compact Framework二进制版本1.0.84。和Windows Vista和.net 3.5

我正在使用SharpDevelop。我看到了其他一些处理这个问题的帖子,但我认为那些是32位与64位问题,通过修改某种形式的Visual Studio中的项目属性来解决,我没有使用。我还检查了我的IDE中的项目属性,我可以看到的所有选项都指向x86和32位。我也尝试在属性中使用“Any CPU”而没有运气。

以下是相关代码:

try{

 SQLiteConnection conn;

 conn = new SQLiteConnection("Data Source=C:\\my path");

 conn.Open();
 conn.Close();
}
catch (SQLiteException ex){
   throw new Exception(ex.Message);

}

这是我在调试中运行时遇到的异常: 我替换了我的本地路径。

System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception de HRESULT: 0x8007000B)
in System.Data.SQLite.SQLite3.Open
in System.Data.SQLite.SQLiteConnection.Open
in mypath 
in System.Windows.Forms.Control.OnClick
in System.Windows.Forms.Button.OnClick
in System.Windows.Forms.Button.OnMouseUp
in System.Windows.Forms.Control.WmMouseUp
in System.Windows.Forms.Control.WndProc
in System.Windows.Forms.ButtonBase.WndProc
in System.Windows.Forms.Button.WndProc
in ControlNativeWindow.OnMessage
in ControlNativeWindow.WndProc
in System.Windows.Forms.NativeWindow.DebuggableCallback
in         ComponentManager.System.Windows.Forms.UnsafenativeMethods.IMsoComponentManager.FPushMessageLoop
in ThreadContext.RunMessageLoopInner
in ThreadContext.RunMessageLoop
in System.Windows.Forms.Application.Run
in mypath

此外,当我添加SQLite.Interop.084.dll作为参考时,我收到有关错误图像文件或没有元数据的警告。 “本地副本”选项在属性中显示为灰色。

我替换旧版本的DLL(1.0.66),现在我得到“MSB3247 - 在同一个依赖程序集的不同版本之间发现冲突”

我删除了项目文件夹中的所有内容,并从头开始,但我一直卡住了。是否有人成功实施了Compact Framework的解决方案?任何人都可以建议一个可以在掌上电脑中使用的类似数据库管理器吗?

  • 我在1.0.66版本上挣扎了几个小时后回到了1.0.84版本。现在我收到此消息:无法在c:\ dev \ sqlite \ dotnet \ System.Data.SQLite下加载文件SQLite3.c。

该路径必须来自他们开发dll的机器,所以我猜测适配器有问题。我想我现在宁愿尝试使用不同的数据库软件,所以我想在这一点上我会就此提出建议而不是解决方案。

对此的任何帮助将不胜感激。

2 个答案:

答案 0 :(得分:3)

好的,所以我尝试了“常规”Windows版本,并且第一次尝试就可以了。我什么都没做。不幸的是,我需要开发一台掌上电脑,所以我还是搞砸了

我认为Compact Framework的二进制文件有一些缺陷,C#的模糊异常也不是很有用。我想二进制文件是为64位机器开发的,就这样离开了。

基本上,使用System.Data.SQLite for Windows Compact Framework,无法完成版本1.0.66或1.0.84。至少开箱即用。我会寻找另一个版本,看看会出现什么。

*我知道这篇文章没有得到“很多”回复,但如果我正在寻找这些信息,我想找到相关的内容,所以我就把它放在这里。

答案 1 :(得分:0)

一段时间后,我尝试做同样的事情,我有一个项目来实现这个

enter image description here

解决方案是取消选中首选 32 位框并使用“x86 平台”目标,即使这将使用双重资源进行下载。