Rashim's Blog

Could not load file or assembly ‘System.Data.SQLite.dll’ or one of its dependencies.

Posted on: October 31, 2013

Last couple of months, I was in rush and could not contribute to the community as much as I have been expected, but regularly I have been answering the questions and giving solutions of different technical problems that I have got through e-mail from different know-how guys.  Solving and replying those critical problems engage me 2-3 hours a day and at the same time I have to spend 8-9 hours a day in my office, so it is really tough to allocate time for writing about something new. But, then again, it is all about our part of  life; I would come up writing with new and cutting edge technologies very soon again.

Today I would like to give a solution of a weird problem that I had confronted for deploying SQLite.

”Could not load file or assembly ‘System.Data.SQLite.dll’ or one of its dependencies.”

For solving this issue I had tried a whole variety of ways but had not got my problem solved. What I had done to solve this issue was that I installed   the version sqlite-netFx40-setup-bundle-x86-2010-1.0.89.0 and then copy the System.Data.SQLite.dll to my project folder and refer this dll to my project. It solved the problem in my development PC but when I had gone for deployment I had got another error which is like that,

“Unable to load DLL ‘SQLite.Interop.dll’: The specified module could not be found. (Exception from HRESULT: 0x8007007E)”

It shows that the native interop assembly is required either for x86 or x64 architecture. As  ‘System.Data.SQLite.dll’  is a mixed mode assembly, I suspected it would automatically loads its native code. But I had got no luck really!! The reason behind this is might be that a particular mixed mode assembly is either for x86 or x64 not for both. Anyway I really don’t know what was the exact reason inside for this issue. After trying in many different ways I had come across the solution finally. Here it is.

First we need to install SQLite and in my case I installed it from NuGet gallery.To do that you can follow the steps that have been given below:

Go to the TOOLS->Library Package Manager->Package Manager Console of the Visual studio.

Image 

  Then run the command Install-Package System.Data.SQLite

Image

Now in your project you have got two folders x86 and x64, underneath this folder you will find those SQLite.Interop.dll’. 

Image

Now go to the properties windows of those dlls and set build action is content and Copy to output directory is Copy always.

Image

Like the way you also need to change the property settings for  ‘System.Data.SQLite.dll’.

That’s it. Now build your app. You are ready to deploy and see it is working perfectly in your client machine too.

Advertisements

8 Responses to "Could not load file or assembly ‘System.Data.SQLite.dll’ or one of its dependencies."

Windows Store App. – getting an error: ” Could not install package ‘System.Data.SQLite 1.0.89.0’. You are trying to install this package into a project that targets ‘.NETCore,Version=v4.5.1’, but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.”

Any idea?

Thank you very much it’s help full to me.

This solved my problem as well! Thank you so much!

thank you, you really a life saver.
I was at the point to remove SQLite from my design.

did you try installing Microsoft Visual C++ 20xx Redistributable? That worked for me, see: http://stackoverflow.com/a/17195350/990618

hi, I am getting same error for “Unable to load DLL ‘SQLite.Interop.dll’: The specified module could not be found. (Exception from HRESULT: 0x8007007E)” and tried your solution but after installing from nuget i am not getting these two folder as shown in your image(https://rashimuddin.files.wordpress.com/2013/10/projectstruture.png).

Hi , I followed your instructions and Sqlite has been installed successfully but there are no x64 nor x86 folder appeared in solution explorer. Any help with this? thank you

Thank you very much.It solve my problem

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: