简体   繁体   中英

SQLite with WPF Application deployment

C# WPF Application with Sqlite not working after deployment. It is working fine when I test the app in the debug folder. I am copying the database.DB file with MSIX Installer In the user's Application folder. But, when I install the Application with setup and try to run it from C://Program Files/Publisher/Application/app.exe it gives no output, no error. Maybe you find that question similar with some other questions like that but i tried their solutions as well but didn't work for me. I am using EF6.
Connection String

<connectionStrings>
    <add name="Default" connectionString="Data Source=|DataDirectory|\tagit.db;Version=3;" providerName="System.Data.SqlClient"/>
</connectionStrings>

MainWindow.xaml.cs

InitializeComponent();
AppDomain.CurrentDomain.SetData("DataDirectory",
         Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData));

Database file path C:\\Users\\darkcoder\\AppData\\Roaming\\tagit.db

After hours of debugging, I finally found the solution.
The project wasn't working due to dependency of SQLite.Interop.dll So I added the file in MSIX Installer Manually and it worked!.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM