C# Windows Forms + Windows 7 + System.Data.SQLite v.1.0.66.0 = crash?

夙愿已清 提交于 2020-01-26 03:24:48

问题


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

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");
        }
    }
}

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.

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


回答1:


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?

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.

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.




回答2:


Have you checked the following:

  • The Windows Event Log (Start > "Event Viewer") to see if anything has been logged that may be of use?
  • That the user you're running the application as has permission to write to the root of drive C:\?
  • That it's specifically SQLLite causing a problem? Try using the code below to verify that it's specifically SQLLite:

Code to create a file manually, o/s of SQLLite:

var file = System.IO.File.CreateText("C:\TextFile.txt");
file.WriteLine("Blah");
file.Close();


来源:https://stackoverflow.com/questions/3389104/c-sharp-windows-forms-windows-7-system-data-sqlite-v-1-0-66-0-crash

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!