diff --git a/Intersect.Editor/Core/Program.cs b/Intersect.Editor/Core/Program.cs index e1292d2b35..2ad153cd73 100644 --- a/Intersect.Editor/Core/Program.cs +++ b/Intersect.Editor/Core/Program.cs @@ -85,20 +85,29 @@ 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, "e_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...");