本文介绍了C# Windows 窗体 + Windows 7 + System.Data.SQLite v.1.0.66.0 = 崩溃?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我目前在使用 Visual Studio 2008 开发的 C# Windows 窗体应用程序中,在 Windows 7 中遇到了非常奇怪的崩溃.

Hey guys, I'm currently experiencing a very strange crash in Windows 7 in a C# Windows Forms application developed in Visual Studio 2008.

该应用程序 - 在 XP 和 Vista 中都运行良好 - 从未真正打开;相反,此应用程序已导致错误并已停止工作".我使用以下源代码制作了一个虚拟应用程序:

The app - which works great in both XP and Vista - never really opens; instead, a "this application has caused an error and has stopped working". I made a dummy application with the following source-code:

using System;
using System.Windows.Forms;
using System.Data.Common;
using System.Data.SQLite;

namespace TesteWin7
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            SQLiteConnection.CreateFile("c:\\mydatabasefile.db3");
        }
    }
}

它仍然崩溃,所以我猜这个问题一定出在我的 DLL 上.将源代码放在 try-catch 块中也是无用的,因为不会输出任何消息.

and still it crashes, so I'm guessing this issue must be on my DLL. Putting the source-code inside a try-catch block is also useless, as no message is outputted.

对此有什么想法吗?我使用的是 System.Data.SQLite 1.0.66.0 版.干杯!

Any thoughts on this? I'm using System.Data.SQLite version 1.0.66.0. Cheers!

推荐答案

我不认为它与 Windows 7 有任何关系.我怀疑是因为您使用的是 32 位 Windows XP 和 Windows Vista,但是 64-bit Windows 7.是这样吗?

I don’t think it has anything to do with Windows 7. I suspect it’s because you used a 32-bit Windows XP and Windows Vista, but a 64-bit Windows 7. Is that the case?

解决方案是将 Visual Studio 项目的平台从任何 CPU"更改为x86".否则,sqlite DLL 将不会加载到您的 64 位进程中,因为它是 32 位的.即使我的理论是错误的并且您使用的是 32 位 Windows 7,您仍然应该这样做,因为如果您不这样做,它仍然会在 64 位系统上崩溃.

The solution to that is to change the platform for your Visual Studio Project from "Any CPU" to "x86". Otherwise the sqlite DLL will not load into your 64-bit process because it is 32-bit. Even if my theory is wrong and you used a 32-bit Windows 7, you should still do that because it will still crash on 64-bit systems if you don’t.

不要担心在 64 位机器上以 32 位方式运行整个进程的性能.这真的没有关系.从 Visual Studio 2010 开始,x86"甚至是默认设置.

Don’t worry about the performance of running your entire process as 32-bit on a 64-bit machine. It really doesn’t matter. Starting with Visual Studio 2010, "x86" is even the default.

这篇关于C# Windows 窗体 + Windows 7 + System.Data.SQLite v.1.0.66.0 = 崩溃?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 22:42