mjb mjb - 1 month ago 19
C# Question

System.IO.FileLoadException: Could not load file or assembly 'System.Data.SQLite

This is a duplicate question and has been asked in stackoverflow.com

Oh, hey, wait. Don't vote me down or close my question.

Yes, I'm aware of this is a duplicated question which has been asked in stackoverflow.com. I have read the answers. I've tried the solutions, but that didn't solve my problem. I'm going to explain what my problem is and what have I done.

This is my problem:

My application used System.Data.SQLite.DLL. I referenced it and run normally in my computer, but it failed to run on another computer. This is the error message:


System.IO.FileLoadException: Could not load file or assembly
'System.Data.SQLite, Version=1.0.88.0, Culture=neutral,
PublicKeyToken=db937bc2d44ff139' or one of its dependencies.
The application has failed to start because its side-by-side

configuration is incorrect. Please see the application event
log or use the command-line sxstrace.exe tool for more detail.

(Exception from HRESULT: 0x800736B1) File name: 'System.Data.SQLite,
Version=1.0.88.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139'
---> System.Runtime.InteropServices.COMException (0x800736B1):
The application has failed to start because its side-by-side

configuration is incorrect. Please see the application event log or
use the command-line sxstrace.exe tool for more detail.

(Exception from HRESULT: 0x800736B1)
at SimPB.config.PrepareDatabase()
at SimPB.config.InitializeProgram()
at SimPB.Program.Main()


My computer is running Windows 7 32 bit, Visual Studio 2010.

Another computer is running Windows 7 32 bit too, without Visual Studio installed.

What I have tried:

Attempt 1: Make sure the application is build with Release + x86 and the application is build with the target framework: .NET Framework 2.0. Done.

Attempt 2: Make sure the application referenced with the correct build of System.Data.SQLite, which is x86 + .Net Framework 2.0 (sqlite-netFx20-binary-Win32-2005-1.0.88.0). Done

Attempt 3: Try these codes at App.config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v2.0.50727"/>
</startup>
</configuration>


and this

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v2.0.50727"/>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
<runtime>
<NetFx40_LegacySecurityPolicy enabled="true"/>
</runtime>
</configuration>


and this

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v2.0.50727"/>
</startup>
</configuration>


Done.

Attempt 4: Try turn off User Account Control on the another computer. Done.

Attempt 5: Try install Visual C++ Runtime on the another computer (I install Visual Microsoft Visual C++ Runtime 2010 Redistributable Package (x86), also tried 2005 verson.). Done.

Attempt 6: Try reinstall .NET Framework 2.0 SP2. Receive error:


You must use "Turn Windows Features On or Off" in the Control Panel to
install or configure Microsoft .NET Framework 2.0 SP2.


Updated: (After reading answers and comments)

Attempt 7: Make sure System.Data.SQLite.DLL is located at the output bin folder. Done

Attempt 8: Double confirm that the another computer is running 32bit Windows 7. Done

Attempt 9: Change the HintPath declaration in .csproj file:

Change this:

<Reference Include="System.Data.SQLite, Version=1.0.88.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=x86">
<HintPath>E:\Developer Soft\SQLite\sqlite-netFx20-binary-bundle-Win32-2005-1.0.88.0\System.Data.SQLite.dll</HintPath>
</Reference>


To this:

<Reference Include="System.Data.SQLite, Version=1.0.88.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=x86">
<HintPath>..\System.Data.SQLite.dll</HintPath>
</Reference>


Done for Attempt 9.

After the above attempts, the result is still the same. The application can run from my computer normally and failed to run on the another computer.

This is an open source freeware, Simple Phone Book. I have committed and uploaded the latest source code to it's source control server at:
http://simpb.codeplex.com/SourceControl/list/changesets (Changeset Number: fd847ac6c406)

Thanks for any advice.

mjb mjb
Answer

I have solved the problem.

Guys, thanks you very much for spending your time and effort in trying to solve this problem. This is much appreciated.

This is how I solve:

Short story:
Use older version of System.Data.SQLite. New version is suspected to have bugs (I could be wrong).

Long story:
I started to recall back why my previous old version of this program is able to be executed on other computer and this new version can't. What are the obvious changes that I have made?

Yes, I have changed the version of System.Data.SQLite.

The old version of System.Data.SQLite used by this program is V1.0.66. The new version that I used is the latest version: V1.0.88, released on 8 August 2013. (Yes, which is about 4 days ago from today).
Read more: http://system.data.sqlite.org/index.html/timeline

Then I decided to abondon the new version (V1.0.88) and used the old version (V1.0.66), and everything back to normal. The program is once again executable on another computer.

I have tried to have a look at the source code of V1.0.88, but I failed to locate the lines of code which causes the problem. The best I can discovered is at the project of System.Data.SQLite.Interop. When I load the solution in Visual Studio 2010, System.Data.SQLite.Interop is preset to build for .NET Framework 4.0. I don't know how to change it. Later, I reload the solution in Visual Studio 2008, the common properties of System.Data.SQLite.Interop showing that it is going to build for .NET Framework 2.0 (which is what I'm looking for), but I fail to build the solution. Some build errors occur. I didn't spend the time to debug it.

I need to develop the program for .NET Framework 2.0, because there are users who are still using Windows XP.

I assume that V1.0.88 contains bugs, but I could be wrong. Anyway, as for current solution, I just stick to V1.0.66.

Thanks again to everyone who had provided help.