From 3342afaa4e791ba42ad4d1a09bc52a84885fb0cc Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 28 Dec 2025 20:15:03 +0000 Subject: [PATCH 1/2] fix: Ensure SQLite DLL is flushed to disk before initialization - Changed FileMode from OpenOrCreate to Create for clean writes - Changed FileAccess from ReadWrite to Write (only need write) - Added explicit Flush(true) to force write to disk immediately - Added file existence verification after extraction - Prevents DllNotFoundException by ensuring DLL is on disk before SQLitePCL.Batteries_V2.Init() This fixes the "Dll was not found" error at startup by ensuring the sqlite3.dll file is fully written and flushed to disk before the SQLitePCL library attempts to load it. --- Intersect.Editor/Core/Program.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Intersect.Editor/Core/Program.cs b/Intersect.Editor/Core/Program.cs index e1292d2b35..6aca4b4f43 100644 --- a/Intersect.Editor/Core/Program.cs +++ b/Intersect.Editor/Core/Program.cs @@ -87,18 +87,27 @@ public static void Main(string[] args) //Place sqlite3.dll where it's needed. var dllname = Environment.Is64BitProcess ? "sqlite3x64.dll" : "sqlite3x86.dll"; + var targetPath = Path.Combine(Environment.CurrentDirectory, "sqlite3.dll"); + using (var resourceStream = Assembly.GetExecutingAssembly() .GetManifestResourceStream("Intersect.Editor.Resources." + dllname)) { Debug.Assert(resourceStream != null, "resourceStream != null"); - using (var fileStream = new FileStream("sqlite3.dll", FileMode.OpenOrCreate, FileAccess.ReadWrite)) + using (var fileStream = new FileStream(targetPath, FileMode.Create, FileAccess.Write)) { var data = new byte[resourceStream.Length]; resourceStream.Read(data, 0, (int)resourceStream.Length); fileStream.Write(data, 0, data.Length); + fileStream.Flush(true); // Flush to disk immediately } } + // Verify the DLL was extracted successfully + if (!File.Exists(targetPath)) + { + throw new FileNotFoundException($"Failed to extract {targetPath}"); + } + ApplicationContext.CurrentContext.Logger.LogTrace("Libraries unpacked."); ApplicationContext.CurrentContext.Logger.LogTrace("Initializing SQLite..."); From 33817dcec69782abc201ebafd599b928e2ecff50 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 28 Dec 2025 20:17:09 +0000 Subject: [PATCH 2/2] fix: Extract SQLite DLL as e_sqlite3.dll for bundle_e_sqlite3 package The SQLitePCLRaw.bundle_e_sqlite3 package expects the native DLL to be named 'e_sqlite3.dll', not 'sqlite3.dll'. Changed the target filename when extracting the embedded SQLite DLL to match what the package expects. This resolves the DllNotFoundException: "Dll was not found" error that occurred during SQLitePCL.Batteries_V2.Init() at startup. --- Intersect.Editor/Core/Program.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Intersect.Editor/Core/Program.cs b/Intersect.Editor/Core/Program.cs index 6aca4b4f43..2ad153cd73 100644 --- a/Intersect.Editor/Core/Program.cs +++ b/Intersect.Editor/Core/Program.cs @@ -85,9 +85,9 @@ public static void Main(string[] args) ApplicationContext.CurrentContext.Logger.LogTrace("Unpacking libraries..."); - //Place sqlite3.dll where it's needed. + //Place e_sqlite3.dll where it's needed (required by SQLitePCLRaw.bundle_e_sqlite3). var dllname = Environment.Is64BitProcess ? "sqlite3x64.dll" : "sqlite3x86.dll"; - var targetPath = Path.Combine(Environment.CurrentDirectory, "sqlite3.dll"); + var targetPath = Path.Combine(Environment.CurrentDirectory, "e_sqlite3.dll"); using (var resourceStream = Assembly.GetExecutingAssembly() .GetManifestResourceStream("Intersect.Editor.Resources." + dllname))