title: Deploying a Windows 8 Metro application that uses SQLite
body: <p><strong>Background</strong></p>
  
  <p>We're using System Center 2012 to deploy a Windows 8 Metro-style application to Samsung slates in the field running Windows 8 Enterprise x64.  The slates are joined to the domain and have a persistent DirectAccess connection back to it, allowing System Center to push applications and updates to the devices.  </p>
  
  <p>We have to deploy our application to potentially hundreds of devices in the field, which is why we went the System Center route.  The code signing cert is installed on every device using Group Policy.  To deploy the application, you simply provide the package output and specify the collection of devices to install it on. The app just shows up on the device in a few minutes.</p>
  
  <p>The problem we're having is that when System Center deploys our application, the SQLite dependency is lost and none of our data access works. </p>
  
  <p><strong>About our project</strong></p>
  
  <p>Our application is a WinJS application that uses SQLite as a backend.  However, all our data access code is in a C# WinMD project which the WinJS project references. We're using the <a href="https://nuget.org/packages/sqlite-net">sqlite-net</a> library to talk to SQLite - we included the source for that in our C# project.</p>
  
  <p>In Visual Studio, we installed the <strong>SQLite for Windows Runtime extension</strong> as described in <a href="http://timheuer.com/blog/archive/2012/08/07/updated-how-to-using-sqlite-from-windows-store-apps.aspx">Tim Heuer's article</a>.  The Metro application references this. </p>
  
  <p><strong>Testing using other deployment methods</strong></p>
  
  <p>SQLite data access from the application works fine when you debug or run it locally - in both Debug/Release and x86/x64.</p>
  
  <p>The app packaging process provides a PowerShell script that you can use to install the application and a developer license if necessary.  When installing our app using the PowerShell script, SQLite data access also works fine.  Verified this by packaging and installing both Debug/Release and x86/x64 versions of the app.</p>
  
  <p><strong>Troubleshooting</strong></p>
  
  <p>When the application first tries to use SQLite, we see an exception about it not being able to find the sqlite3.dll. </p>
  
  <p>We've tried/verified the following:</p>
  
  <ul>
  <li>Confirm that we're deploying a Release/x64 build</li>
  <li>Examine the appx in WinRAR and verify that it contains the sqlite3.dll</li>
  <li>Reference the "SQLite for Windows Runtime" extension from the C# project instead of the WinJS project</li>
  <li>Also reference the C++ runtime, this caused System Center to fail when deploying the app. Don't know why yet, but looking into it. </li>
  </ul>
  
  <p><strong>UPDATE</strong>
  The issue is that System Center is having trouble deploying the Visual C++ Runtime Library dependency that the SQLite library needs. So unfortunately this isn't a programming question anymore.  We're getting some help on this and I'll post the fix.</p>