Oh, I do remember having this issue before.

I think the cause is this: Visual studio attempts to trace which dlls are 
required for each project. Then if project A is dependent on project B, visual 
studio will copy what it thinks is all the required dlls for both projects into 
project A's output directory.

Unfortunately visual studio is only so smart and doesn't realise that the 
SQLite.interop.dll is a required dependency. I believe the NuGet package puts 
instructions to move those dlls to the output directory by means of xcopy. So, 
you have this situation:

Project GlobalSQLite, with reference to SQLite.
Project GeneologyControls, with reference to GlobalSQLite.

Tell visual studio to build and it goes and executes the step where the SQLite 
interop DLL is copied to the output of the GlobalSQLite project. But then it 
builds GeneologyControls and doesn't realise it needs to copy the interop DLLs! 
So finally your program executes in the output directory of the 
GeneologyControls project, but the SQLite.interop.dll files are in the output 
of the other project.

You need to ensure that the SQLite interop dlls are in the final output 
directory (and also included when you distribute your application). You can do 
this manually using windows explorer, or you can put in a pre or post build 
event of your final project to copy the x64 and x86 folders (containing the 
SQLite.interop.dll files) into its output directory. Doing it from Windows 
explorer is easier, but you may forget then if you do a clean build a few years 
down the line you'll run into the problem again.

Perhaps there's a cleaner way to do this. Those were my solutions, though...

> On 23 Feb 2017, at 1:58 PM, Clyde Eisenbeis <cte...@gmail.com> wrote:
> 
> -------------------
> About two years ago, I downloaded and installed SQLite.  I don't
> recall the details, but it was a program that installed SQLite.
> 
> I ended up with files such as EntityFramework.dll,
> EntityFramework.SqlServer.dll, System.Data.SQLite.dll, etc.  This
> required "using System.Data.SQLite".
> 
> -------------------
> I then created a WPF C# genealogy program ... and a GlobalSQLite.dll
> library (as a WPF Custom Control Library).
> 
> The GlobalSQLite.dll library contains commonly used functions.  For example:
> 
>   boCreateFileAndTables(string stPathFilename,
>                         List<string> liststTableNames,
>                         List<string> liststFieldDefinitions)
>   {...}
> 
> -------------------
> I am working to improve / clean up the original code for WPF C#
> genealogy program.
> 
> When I have SQLite installed on my genealogy program and on my
> GlobalSQLite.dll library, it works fine.
> 
> When I don't have SQLite installed on my genealogy program, I get an
> exception "Unable to load DLL 'SQLite.Interop.dll'".  It occurs in my
> GlobalSQLite.dll library program:
> 
>    sqliteConn = new System.Data.SQLite.SQLiteConnection("Data
> Source=" + stPathFilename + ";").
> 
> I do find SQLite.Interop.dll under ...
> GlobalsSQLite\packages\System.Data.SQLite.Core.1.0.101.0\build\net46\x86
> ... and under ... \x64.
> 
> Is there a better place to put SQLite.Interop.dll so it works?
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to