How do I get UWP Uninstall to remove database completely? - entity-framework-6

I have managed to get an XAF application into the Windows Store via the Desktop Bridge.
When a user installs my software from the Windows Store and then chooses to uninstall,
I want them to have the option to completely uninstall the software including the database.
So that they won't have any problem should they later decide to re-install?
Currently, the UWP uninstall does not give an option to delete the database ( or even explain how to delete it ) Thus the user may be tempted to delete the data files via Windows Explorer - which still leaves some instance of LocalDB maintaining an entry in its list of databases.
Thus on a second install after deleting the database files, the UWP program displays the error
"Login failed for user"
As explained in this question
My connection string is using
(localdb)\mssqllocaldb
How do I automate removing the database and memory of it completely?
i.e What uninstall event can I use, What do I override where?
I can't see any executable code in the Desktop Bridge itself.
At the moment I think I may need to put "Run This Before You Uninstall" option in the actual program.
Or perhaps as a workaround, I should code a Clean Up handler for the "Login failed for user" error.
This issue is related
I am using Entity Framework 6.2 and .Net Framework 4.7.2
The Bridge Project is using Windows 10, version 1809, Build 17763 ( Min and Target)

See Getting Started with EF Core on Universal Windows Platform (UWP) with a New Database. It introduces use of migrations. Migrations are designed to help you change your database design and implement the changes in production. Migrations can be frustrating though because Microsoft has not documented the feature thoroughly. There is a list somewhere of the migration features not supported for SQLite; it is important to know about that from the beginning.

Related

Downgrading an MSIX-installer application after setting ForceUpdateFromAnyVersion

We have an application that we distribute internally on a network share with an MSIX package. We make the MSIX package with the MSIX project type in Visual Studio. Users install it with the index.html page that is created.
We want to rollback changes in case an update goes seriously wrong, so I've created an .appinstaller template and use it to set the ForceUpdateFromAnyVersion flag.
My question is how does a user actually perform a downgrade? I've tried to browse to an earlier version in Windows Explorer and execute the .msixbundle file, but it tells me that a newer version of the app is already installed and my only option is to launch the currently installed version.
I've only just discovered this ForceUpdateFromAnyVersion flag last week and we create weekly releases, so the version that has that flag set is the current version. Is that the reason downgrading doesn't work?
To perform a downgrade, place the appinstaller file on the share near the MSIX/MSIXBUNDLE and instruct the users to install the application via the appinstaller file (double click the appinstaller).
Only then the downgrade scenario will work. The msixbundle does not contain the ForceUpdateFromAnyVersion and it's not aware of it unless you use the appinstaller, that is why, when you try to downgrade via the msixbundle you receive the error that a new version is present on the machine.
What you must consider is this: if the user installed the MSIX/MSIXBUNDLE first, and then you publish the appinstaller file with the old version on your share, the downgrade will not happen automatically, because the MSIX on the user machine does not know that he has to check any share for updates/downgrades. All of the auto-update options are defined in the appinstaller.
But if your users installed the application via the appinstaller first, you can then put a new appinstaller file on your share (and MSIX/MSIXBUNDLE of course) which points to a lower version, and depending on how you defined the check interval in the appinstaller file, the downgrade will be performed automatically..
From what I read (I didn't test it) it seems that indeed the flag needs to be present in the appinstaller of the version that is checking for updates (not just in the new version). So, with the next update you should be able to push an downgrade.
Here is a more details tutorial from Microsoft on MSIX downgrades.

How can I activate Xamarin.Android for use on a CI server?

My company owns several business licenses for Xamarin.Android, and we'd like to use this on our CI server. However, it seems that I'd need to install the full Xamarin suite on my CI server including Visual Studio Pro to make this work. My question is, using the vanilla Xamarin.Android package, how can I activate it?
It seems that installing this on its own adds the Xamarin.Android tools and libraries to build with but there is no way to activate it that I can find, so when I attempt to build using MSBuild, the build fails with this error:
C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(299,2): error XA9008: Building from the command-line requires aÿBusinessÿLicense.
Now, after some googling, I have found that the activation tool is called "mandroid.exe", which can be found in C:\Program Files (x86)\MSBuild\Xamarin\Android - although I have found references to this being in the 64-bit program files too.
Unfortunately, I can't find any suitable documentation on this tool. Every time I find a thread where someone discusses this, someone from Xamarin jumps in and says "contact support#xamarin.com". After a while I did that but two business days later there still is no response and I've got deadlines to meet so I thought it might be helpful for everyone involved for us to publicly document this process.
The best thing I've found comes from a thread on the Xamarin mailing list which references this invocation:
mandroid.exe --activate --name "NAME" --company "COMPANY" --email "EMAIL" --phone "PHONE" --code "ACTIVATION CODE"
I have also discovered another variant of this invocation that looks like this:
.\mandroid.exe –activate –activation-name="NAME" –activation-phone="PHONE" –activation-company="COMPANY" –activation-code="CODE" –activation-email="EMAIL"
I've tried many permutations of my account data here using both invocations - using the activation code from the products page on the Xamarin store. No matter what though, this error occurs:
\mandroid.exe : monodroid: error XA9997: Incomplete data provided to complete activation
In the "problems activating?" section of the products page, it says this:
In Mono for Android 1.0.21316 and later, if activation within Visual Studio fails then a MfaActivation.dat file will be created within the Documents folder. Select this file below.
Perhaps there's some way to force this file to be created by mandroid.exe? That would be very helpful. While I imagine that offline activation is the only way to make this work, I would accept any answer that involves uploading MfaActivation.dat or otherwise invoking the online activation machinery as well.
Update - I'm afraid that the below steps no longer work. Xamarin has updated their activation system to activate by a different method for newer versions.
In the end I had to install Xamarin Studio as part of the Chef configuration and just instruct administrators to manually activate the software as part of creating a new build node. I had no luck trying to reverse engineer a fix, and if I did, it would probably just break again.
It turns out that I almost had it correct. The second invocation I specified is actually the correct way to call this command but the -- part was apparently converted to a – token by some blog software somehow.
The --activate verb will perform an online activation with Xamarin's servers, so I'm still not sure how you'd do it without an internet connection.
For reference, here is how I did it:
mandroid.exe -v --activate --activation-name "(NAME)" --activation-phone "(PHONE_" --activation-email "(EMAIL)" --activation-company "(COMPANY)" --activation-code "(CODE)"
I'm not sure about the significance of the -v switch, but perhaps that would make it output debugging info if there was a problem.
You must enter all the information exactly as specified on your products page - select one of your licenses and select "problems activating?". However, you will need to enter the licensee name - i.e. the user who owns the license in the --activation-name parameter which must correspond to the --activation-code parameter.
After doing this you can call mandroid with the --activated switch which returns an exit code:
PS> & .\mandroid.exe --activated
PS> $LastExitCode
0
You will also be able to reload the products page and you should see that your license for the chosen user has a new computer registered to it.
This does use up another activation but if you e-mail the support team you can sign the build server agreement and then I assume they can set you up with additional activations for your build nodes.
It's a shame that this wasn't documented better because this has wasted my time for several days. Hopefully this will be helpful to someone else with the same situation.
From Xamarin documentation, we can see
http://docs.xamarin.com/guides/cross-platform/ci/configuring_tfs/
"Visual Studio Professional (or greater) must be installed on the Team
Foundation Server along with licensed copies of Xamarin.Android and
Xamarin.iOS to support development of Android and iOS mobile
applications via the Team Foundation Server."
So I assume that in all cases you need to have VS + Xamarin products installed and activated.
I might be wrong, so the best way is to contact Xamarin support, http://xamarin.com/support

Radstudio and Interbase license issue?

I had my RadStudio setup all working and have created a very simple mobile app for android that uses IBLite to grab some data. For business reasons I had to leave the project and move on to other things. So I come back to Radstudio thinking I can just pick up where I left off.
I notice there is an update for the product so I apply the changes and then open up my previous project. From there things get very strange. I can build and deploy to android and the project still works. If I deploy to IOS simulator again no problem and everything works fine. As soon as I try to deploy to a device I get the following compiler error:-
[DCC Error] E2597 ld: library not found for -libtogo
(This is an outstanding question on Embarcadero Developer Forum)
Which looks to me like a problem with the licence file. So I try to manually add it to the deployment but still get the error. So I decided to park my project and go back to the IOS IBLite tutorial from the Embarcadero website. I get to the stage where I want to drop an sqlconnection to the form and connect to the database... No joy it comes up with unavailable database which I thought might be a licensing issue or the fact the IB Server was not running. So I double checked the latter and sure enough it is running as a windows service and I can use IBConsole to connect to it.
So I drop trying to create a mobile application and try to create a desktop app that connects to the dbdemos database. No luck, the ide still states unavailable database...
So to my question?
How do I get radstudio to pick up the license for Interbase and particulary IBLIte for IOS?
I have searched online and on the EDF and have been unable to find a solution.
Take a look to this link.
IBREDISTDIR environment variable should be properly configurated with the directory containing library folders and licenses.
RAD Studio links statically libibtogo.a probably this file is missing. This file usually is into ($BDS)/lib/iosDevice/debug path

Service installed on Windows 7 machine is not reading from its config file

I have a .Net 3.5 web service that installs perfectly on my old XP box. I recently got a beautiful new Windows 7 box and everything has been working wonderfully. Yesterday I remembered that I need to instal this service on my new box and attempted to perform the install.
After the install I did a quick test and it seemed to be working correctly. Later in the day, I went into the config file and made a small change. After restarting the service I was dismayed to discover that the change was NOT being picked up by the service and it continued to use the old values.
Can someone explain how this is possible? I am totally befuddled here.
You've most likely been a "victim" of Windows Backward Compatibility (aka UAC Data Redirection).
When a program running as non-admin tries to write to config files located in Program Files, Windows redirects the write to another (user local) directory. That means, a user can seemingly write the file, but another user will see the original, Program Files, version.

Automatic program update and Windows 7

We have a suite of programs that check for new versions at startup, and then download new versions to run if required. This is obviously a problem in Windows 7, when it is locked down as a 'standard user', as they can't write to the c:\program files directory and below. Anyone seen a example of an application that gets around with issue ?
Our applications are written in Delphi, but an example in any language would be useful.
Thanks in advance
Update:
We already have a system for determing whether a new version exists, the only problem is the download and install (if required), as this requires elevation. I can't think of a way that doesn't require an elevation prompt, or our users to reduce their security settings.
Update 2 :
I've asked a subsequent question, rather than adding a new one here
There are two options for application installation:
Application is available for all users: installation or update requires elevation for Windows Vista and up
The application is available for one user: install or update the application in the user profile in %LOCALAPPDATA%, no elevation is required
Ad 2: Google Chrome does this. It installs the .exe here:
%LOCALAPPDATA%\Google\Chrome\Application\chrome.exe
--jeroen
Typically what you will see an application do if it needs to escalate permissions is something like this.
Application determines if upgrade is needed
Application launches an "updater" service that requires "Administrator" permissions
Application updates itself with this updated
Application re-starts
This is a pretty common scenario, especially since to update your own DLL you need to go to a secondary process anyway.
Here are some tips for you to get around updating challenges:
If your file is names 'update.exe' or 'install.exe' then it will automatically force a UAC elevation prompt. This is an easy way to make existing software bypass Windows Vista/7 permissions.
It is not a good idea to have the update checking and update process managed from within your application. The problem is that your app is likely to lock files and need updating itself. An external app should manage your updates.
The simplest update solution is to make an HTTP call that checks for the current product version number, and then download the installer binary if necessary. This won't give you any flexibility in updates, but it is a quick and easy solution.
Our company sells software that specifically helps with automatic updates on Windows 7 UAC (you can visit AutoUpdate+ by clicking here: link text). The best reasons for using a third party solution - any solution - are that you will have more flexibility with your updates and also avoid the finicky challenges of supporting different Windows releases.
Or you can have it so that the user runs a launcher app.
The application uses the LOCALAPPPATH\ folder to store a cache of the main application.
Launcher checks to see if the internet has newer version of file(s) than the cached file.
Launcher launches the cached application in LOCALAPPPATH
Your app can check if a new version is available on the remote server. If it does, then it can download update files in one of user-specific folders, like user's temp folder. You can get address of such special folders using SHGetSpecialFolder API function.
Once the download is done, you can pop up a dialog box telling user that you are ready for update. If user agrees with update, then you can run the updater process with elevated privileges (as administrator), and updater process can replace existing files in your installation path with the ones already downloaded in user Temp folder. To run your updater as administrator, you can use ShellExecute:
ShellExecute(0,'runas','notepad.exe',nil,nil,SW_SHOWNORMAL);
When updating is done, your updater process can restart your app.
You need to have a separate executable to the updating work. The updater needs to have a manifest that marks it as requiring elevation.
See: http://msdn.microsoft.com/en-us/library/bb756929.aspx
If your application uses MSI (Windows Installer) for its installer, then User Account Control Patching, if properly configured, can let you install updates without elevation.
If your installer wasn't run under admin - you don't need any additional rights to install update.
If your installer was run under admin - then it can create a task in Task Sheduler. Say, run this task once a week, under this account (admin) and with highest privs. Task will be your updater. Simple.

Resources