1
votes

I've packaged my WinForms app with Desktop Bridge, but running the app fails with a Unhanadled exception.. "Unable to open database. Connection string "Data Source="Test.db";

In my WinForms app the db is located in the bin/x86/debug folder. It can't find my database.

What do I modify in the Winforms app to make it Microsoft Store/UWP runnable?

2
I assume you have already verified that Test.db is indeed included in your package? If yes, then my guess is you are missing this: blogs.msdn.microsoft.com/appconsult/2017/06/23/…Stefan Wick MSFT
Yes Stefan, the db is included. So I need to go back and change the code from a WinForms app.per the blog..I guess this makes the Desktop Bridge more of a Bridge Over Troubled Code (Waters).Trey Balut
If you can change the app code that would be the easiest way to make it work. Alternatively, you can include a small launcher EXE in your package that sets up the current directory for your app process. Then you won't need to change your app code.Stefan Wick MSFT

2 Answers

2
votes

Use the following API for the Storagefolder:

https://docs.microsoft.com/en-us/windows/uwp/get-started/fileio-learning-track

with in your winforms application for file storage of the SQL lite database.

0
votes

I was able to use sqlite without using the storage API. I used the entire path and saved the DB to public docs.

another solution is to use an installer framework like Advanced Installer.

They have a simple wizard that allows to simply declare where you want it without awkward code work-arounds.