Home > SQLite > Unable to load DLL ‘SQLite.Interop.DLL’

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”

About these ads
Categories: SQLite Tags:
  1. none
    March 8, 2013 at 3:05 am | #1

    Thanks, that helped. Make sure you use the correct version (64 vs. 32 bit)

  1. No trackbacks yet.

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 )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: