Unable to load DLL ‘SQLite.Interop.DLL’
I am working on a ASP .NET MVC 3 project and decided to use SQLite. I found a great Code Project article titled SQLite Membership, Role, and Profile Providers by Roger Martin. He made SQLite providers similar to those for SQL Server. I decided to follow the article step-by-step. After build, I opened the Security tab of the ASP .NET Web Site Administration Tool page (via the ASP .NET Configuration item under the Project menu), and got the following error message:
Unable to load DLL ‘SQLite.Interop.DLL’: The specified module could not be found. (Exception from HRESULT: 0x8007007E)
It seems that the System.Data.SQLite DLL needs the SQLite.Interop DLL in the same directory. So we’ll just need to copy that DLL to our bin directory. Of course, we would want to have Visual Studio do it automatically for us when we build our project. If you have added the DLL to your project you can set the “Copy to Output Directory” property of the said DLL. That is, it should not be inside a subfolder of the project. Otherwise, the DLL will be inside a subfolder in the output directory.
If the DLL is in a sub-folder we can still use Build Events. In the project properties, go to Build Events and put the following command in either the Pre-build or Post-build event command line (assuming that you have put the SQLite.Interop DLL in a lib subfolder):
Copy “$(ProjectDir)lib\SQLite.Interop.dll” “$(ProjectDir)$(OutDir)SQLite.Interop.dll”
Thanks, that helped. Make sure you use the correct version (64 vs. 32 bit)