Embed System.Data.SQLite.dll and SQLite.Interop.dll (x86/x64)
System.Data.SQLite.dll is a managed assembly but depends on the native SQLite.Interop.dll for both x86 and x64. With BoxedApp SDK, you can ship a self-contained app by exposing these binaries as virtual files backed by embedded resources, so the runtime resolves them without writing anything to disk.
Project Setup (Embedded Resources)
Add a folder EmbeddedResources and place the following files inside: EmbeddedResources/System.Data.SQLite.dll, EmbeddedResources/x86/SQLite.Interop.dll, and EmbeddedResources/x64/SQLite.Interop.dll.
Set the Build Action to Embedded Resource for all three files so that GetManifestResourceStream can access them:

Initialize BoxedApp SDK
Initialize the SDK early, before any assemblies are loaded or SQLite is initialized.
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
// Initialize BoxedApp SDK first
BoxedAppSDK.NativeMethods.BoxedAppSDK_Init();Create Virtual Files from Embedded Resources
Expose three virtual paths that match your probing expectations (the current directory and the x86/x64 subfolders).
CreateVirtualFile(Path.Combine(Application.StartupPath, "System.Data.SQLite.dll"), "SqliteEmbeddingSample.EmbeddedResources.System.Data.SQLite.dll");
CreateVirtualFile(Path.Combine(Path.Combine(Application.StartupPath, "x64"), "SQLite.Interop.dll"), "SqliteEmbeddingSample.EmbeddedResources.x64.SQLite.Interop.dll");
CreateVirtualFile(Path.Combine(Path.Combine(Application.StartupPath, "x86"), "SQLite.Interop.dll"), "SqliteEmbeddingSample.EmbeddedResources.x86.SQLite.Interop.dll");The CreateVirtualFile method creates a virtual file using data from an embedded resource. First, it calls BoxedAppSDK_CreateVirtualFile, which returns a virtual file handle. It is a good idea to close this handle immediately after obtaining it, since you don’t need it, and closing helps avoid leaks. Using SafeFileHandle from Microsoft.Win32.SafeHandles ensures the handle is closed automatically. Then CreateVirtualFile opens the virtual file, takes a stream from the embedded resource, and copies all the data from one to the other:
static void CreateVirtualFile(string virtualFilePath, string embeddedResourceName)
{
// Create virtual file and immediately close the handle to avoid leaks
using (SafeFileHandle hHandle =
new SafeFileHandle(
BoxedAppSDK.NativeMethods.BoxedAppSDK_CreateVirtualFile(
virtualFilePath,
BoxedAppSDK.NativeMethods.EFileAccess.GenericWrite,
BoxedAppSDK.NativeMethods.EFileShare.Read,
IntPtr.Zero,
BoxedAppSDK.NativeMethods.ECreationDisposition.New,
BoxedAppSDK.NativeMethods.EFileAttributes.Normal,
IntPtr.Zero
),
true
)
)
{
using (Stream embeddedResourceDataStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(embeddedResourceName))
{
const int bufferSize = 1024;
byte[] buffer = new byte[bufferSize];
int readBytes;
using (FileStream virtualFileStream = new FileStream(virtualFilePath, FileMode.Open))
{
while ((readBytes = embeddedResourceDataStream.Read(buffer, 0, bufferSize)) > 0)
virtualFileStream.Write(buffer, 0, readBytes);
}
}
}
}Usage
Once the virtual files exist, open your SQLite connection as usual. The runtime will load the managed and native binaries directly from the virtual file system.