Archive for October 2013
Posted October 31, 2013on:
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-188.8.131.52 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.
Then run the command Install-Package System.Data.SQLite
Now in your project you have got two folders x86 and x64, underneath this folder you will find those ‘SQLite.Interop.dll’.
Now go to the properties windows of those dlls and set build action is content and Copy to output directory is Copy always.
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.