{"id":61,"date":"2016-02-11T15:31:51","date_gmt":"2016-02-11T15:31:51","guid":{"rendered":"https:\/\/ibex.tech\/csharp\/?p=61"},"modified":"2022-02-17T06:24:15","modified_gmt":"2022-02-17T06:24:15","slug":"adding-sqlite-to-a-project","status":"publish","type":"post","link":"https:\/\/ibex.tech\/csharp\/c-sharp\/databases\/sqlite\/adding-sqlite-to-a-project","title":{"rendered":"Adding SQLite to a project"},"content":{"rendered":"<p>\n\tGet the latest set of files from&nbsp;<a href=\"http:\/\/system.data.sqlite.org\/index.html\/doc\/trunk\/www\/downloads.wiki\">system.data.sqlite.org<\/a>\n<\/p>\n<p style=\"margin-left: 40px;\">\n\tBinary packages are intended to be used for development and deployment of their applications onto customer machines. &nbsp;Ensure you select the correct version for&nbsp;the .NET Framework version and Windows 32\/64bit version&nbsp;your applicaiton targets. &nbsp;Select the version without &#39;mixed-mode assembly&#39; bundle.\n<\/p>\n<p style=\"margin-left: 40px;\">\n\t(Setup packages are intended for developer machines if the design-time components for Visual Studio are required).\n<\/p>\n<p>\n\tSo this is what we do, we want the distribution binaries and we want them statically linked with the visual C++ runtime library in case the user doesn&#39;t already have it on their machine. &nbsp;So this is what we would choose for example:\n<\/p>\n<p style=\"margin-left: 40px;\">\n\tPrecompiled Statically-Linked Binaries for 32-bit Windows (.NET Framework 4.0)\n<\/p>\n<p style=\"margin-left: 80px;\">\n\tsqlite-netFx40-static-binary-Win32-2010-1.0.94.0.zip\n<\/p>\n<p style=\"margin-left: 40px;\">\n\tPrecompiled Statically-Linked Binaries for 64-bit Windows (.NET Framework 4.0)\n<\/p>\n<p style=\"margin-left: 80px;\">\n\tsqlite-netFx40-static-binary-x64-2010-1.0.94.0.zip\n<\/p>\n<p>\n\tFrom the zip copy &#39;System.Data.SQLite.dll&#39; into your project directory and then add it as a reference (Menu &gt; Project &gt; Add reference &gt; Browse to it)\n<\/p>\n<p>\n\tCopy the following files \/ directories to&nbsp;your executables directory (debug and release). &nbsp;These&nbsp;don&rsquo;t need to be added as a reference in your project:\n<\/p>\n<p style=\"margin-left: 40px;\">\n\t\\System.Data.SQLite.dll (required, managed-only core assembly, from either zip)<br \/>\n\t\\System.Data.SQLite.Linq.dll (optional, managed-only LINQ assembly)<br \/>\n\t\\System.Data.SQLite.EF6.dll (optional, managed-only EF6 assembly)<br \/>\n\t\\x86\\SQLite.Interop.dll (required, x86 native interop assembly)<br \/>\n\t\\x64\\SQLite.Interop.dll (required, x64 native interop assembly)&nbsp;\n<\/p>\n<p>\n\tSet the projects .Net framework to match that used and ensure your distribution package \/ installer is set to install it as a prequesit if necessary.\n<\/p>\n<p>\n\tThats it! &nbsp;\n<\/p>\n<h4>\n\t32bit vs 64bit<br \/>\n<\/h4>\n<p>\n\tYour project needs to be set to the same platform architecture as that being used for the sqlite dll&#39;s. &nbsp;For C# developers this means not selectecting&nbsp;&#39;Any CPU&#39; (Project Properties &gt; Build &gt; Platform target). This means if your main executible will need to be created as 32bit and 64bit and deployed according to the target machine architecture. &nbsp;Yes sucks, but sqlite uses unmanaged code in its dll so tough!\n<\/p>\n<p>\n\tThe x86 and x64 directories will likely solve development issues but if not see the &quot;Using Native Library Pre-Loading&quot;&nbsp;notes <a href=\"http:\/\/system.data.sqlite.org\/index.html\/doc\/trunk\/www\/downloads.wiki\">here<\/a> for an important note about managed code applications and 64 vs 32 bit development.\n<\/p>\n<h4>\n\tDistributing&nbsp;Your Application<br \/>\n<\/h4>\n<p>\n\tThese files from your projects release output folder need to be copied into the applications executable when installed on a users PC:\n<\/p>\n<p style=\"margin-left: 40px;\">\n\t\\System.Data.SQLite.dll (required, managed-only core assembly)<br \/>\n\t\\System.Data.SQLite.Linq.dll (optional, managed-only LINQ assembly)<br \/>\n\t\\System.Data.SQLite.EF6.dll (optional, managed-only EF6 assembly)<br \/>\n\t\\x86\\SQLite.Interop.dll (required, x86 native interop assembly)<br \/>\n\t\\x64\\SQLite.Interop.dll (required, x64 native interop assembly)&nbsp;\n<\/p>\n<p>\n\tEnsure the relevant .Net framework is used.\n<\/p>\n<h4>\n\tIssues<br \/>\n<\/h4>\n<p>\n\tC# application targetting &#39;Any CPU&#39; (Project Properties &gt; Build &gt; Platform target)&nbsp;may cause errors and need to be changed to the same 32\/64 bit version as that downloaded.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Get the latest set of files from&nbsp;system.data.sqlite.org Binary packages are intended to be used for development and deployment of their applications onto customer machines. &nbsp;Ensure you select the correct version for&nbsp;the .NET Framework version and Windows 32\/64bit version&nbsp;your applicaiton targets. &nbsp;Select the version without &#39;mixed-mode assembly&#39; bundle. (Setup packages are intended for developer machines if [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[],"class_list":["post-61","post","type-post","status-publish","format-standard","hentry","category-sqlite"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/61","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/comments?post=61"}],"version-history":[{"count":1,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/61\/revisions"}],"predecessor-version":[{"id":62,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/61\/revisions\/62"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/media?parent=61"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/categories?post=61"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/tags?post=61"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}