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!
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.
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();