0

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

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

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 块中也是没有用的,因为没有输出任何消息。

对此有什么想法吗?我正在使用System.Data.SQLite版本 1.0.66.0。干杯!

4

2 回答 2

1

我认为这与 Windows 7 无关。我怀疑这是因为您使用的是 32 位 Windows XP 和 Windows Vista,但使用的是 64 位 Windows 7。是这样吗?

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

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

于 2010-08-02T15:27:40.057 回答
0

您是否检查了以下内容:

  • Windows 事件日志(开始 >“事件查看器”)查看是否记录了任何可能有用的信息?
  • 您运行应用程序的用户有权写入驱动器 C:\? 的根目录
  • 是不是特别是 SQLLite 导致了问题?尝试使用下面的代码来验证它是否专门用于 SQLLite:

手动创建文件的代码,SQLLite的o/s:

var file = System.IO.File.CreateText("C:\TextFile.txt");
file.WriteLine("Blah");
file.Close();
于 2010-08-02T15:23:34.937 回答