(UserControl with SQLite) ---> Failed to create components 'UserControl1', System.DllNotFound Excpetion, Unable to Load Sqlite.interop.dll

3

I had a user control with Sqlite. After Compiled and Added to the Tool Box, by dragging it into a new Form,an Error Message as described Below:

"Failed to Create Component 'UserControl1'. The Error Message follows 'System.DllNotFoundException: 'Unable to Load Dll 'Sqlite.Interop.dll' : The Specified Module could not be found. Exception from HResult: 0x8007007E

I googled on this subject, I'm still unable to resolved this issue. But the funny parts is If I hard coded it in the Form by reference and create a new control, the user control worked. Why Drag and Drop had this problem?

One more Question: I'm using Nuget to install sqlite, there are 2 version: 32 and 64 bit: which one should i add as reference? I'm using VS2010 ultimate sp1. Sqlite v 1.0.83.0. Compiled dll as any cpu.

c#
sqlite
dll
interop
asked on Stack Overflow Jan 2, 2013 by SimonOngsk • edited Feb 8, 2013 by chriga

2 Answers

1

If you download correct binary for SQLite then copy SQLite.Interop.dll into your Release or Debug folder according to your project build option.

answered on Stack Overflow Mar 2, 2014 by Elshan
1

I think this is an issue separate from SQLite and more specifically deals with the DLL not being found when you try to drag the user control from the Toolbox. I had the same problem. I was able to programmatically add the user control via Controls.Add(myUserControl) and it worked fine but I couldn't drag it from the Toolbox. Some searching led me to the following link with insight from Hans Passant:

https://social.msdn.microsoft.com/Forums/en-US/e6ba24f2-4f2d-42bd-b2f2-1e00744e0052/dllimport-throws-systemdllnotfoundexception-in-usercontrol?forum=netfxbcl

The gist is that the Designer doesn't know the path for where to look for the DLL. As a test, I hard-coded the path within DllImport i.e. [DllImport(*full path here*)], and I was able to successfully drag the user control from the Toolbox to the Designer. (Make sure you do a build after adding the full path before trying to add the user control!)

Without any major testing, it seems I was then able to then remove the fully qualified path and the Designer seemed to remember where to look. I could delete the user control from the form and add it again without issue. Once I closed Visual Studio and re-opened it, though, dragging and dropping the user control from the Toolbox failed again. Hopefully this information can help someone understand what's going on and/or lead them in the right direction for a solution.

answered on Stack Overflow Jun 24, 2015 by VineAndBranches • edited Jun 24, 2015 by VineAndBranches

User contributions licensed under CC BY-SA 3.0