Freitag, 23. September 2011

SQLite, Visual C++ and migration from .NET 3.5 to .NET 4.0

Recently we migrated our .NET 3.5 based projects to .NET 4.0. With a little self written tool that changes the framework version in the .csproj files (there are a lot of them) and a little maual work the job was quickly done. But then came the testing of the setup made up of the new files. This was were the tragedy began.

New Version of System.Data.SQLite for .NET 4.0
We had problems with the System.Data.SQLite.dll we were using. We found out that you need a new version of the dlls for .NET 4.0 (can be downloaded from the vendors page). That was the easy one.

32 bit or 64 bit
The .NET 4.0 dlls did not fix our issues. Next thing we assumed was the commonly known point that this product does not support AnyCPU compilation, because it is a wrapper around the C library of SQLite. So we assumed we had a x86 / x64 issue. But this was not the case either.

Here come the solution
The point was, that with the .NET 4.0 version of SQLite the Visual C++ runtime seems to be a prerequisite. On our development machines everything worked well due to the installed Visual Studio. But on the setup machines SQLite did not work. So if you migrate from .NET 3.5 to .NET 4.0 and use SQLite, make sure the C++ runtime is installed.


  • Visual C++ Redistributable package 32 bit
    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\10.0\VC\VCRedist\x86]
    Installed = 1 (REG_DWORD)
  • Visual C++ 2010 Redistributable package 64 bit
    [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\10.0\VC\VCRedist\x64]
    Installed = 1 (REG_DWORD)
Found this, besides some other useful hints here, but noticed that the 64bit registry key was slightly wrong, so be aware of that.

Native .NET SQLite
A different approach would be to use the native .NET SQLite port that can be found here. The project is not officially related to SQLite, but it is based on a current version of SQLite of 3.7.7.1. The project seems to be quite active. I hope I will be able to try it out some time. Does anyone have experiences with that?


Keine Kommentare:

Kommentar veröffentlichen