0

I just recently upgraded my WPF application from .NET 4 to .NET 4.5.2. Everything (so far) has appeared to transition quite well, with one exception.

I have a Settings file that refuses to save changes once I do an "in place" upgrade from the old version of the application (running .NET 4) to the new version (running .NET 4.5.2). I can't figure out what's causing it to break. I'm sure more details would be helpful, but I'm not even sure what to include here to be helpful.

Any help would be appreciated.

Edit: By "in place" upgrade, I mean an automatic upgrade where I start the old application up, it communicates with the server and upgrades the application on start.

I just now realized that if I close the application after the "in place" upgrade has occured, and restart it, then the user settings continue to work just fine. It's just the first run after upgrading that they fail to save/change.

CamHart
  • 3,825
  • 7
  • 33
  • 69

1 Answers1

0

I didn't find the reason why this was occuring, only that it was. Since I discovered it only broke the settings for the first time it was ran after the upgrade, I decided to force a restart whenever the application was upgraded.

I only found one way to restart the clickonce application that worked properly. See How do I restart a WPF application?.

To check if a Upgrade occured, within my App.xaml.cs I check IsNetworkDeployed, to make sure the CurrentDeployment isn't null, then I check a user setting that gets set once someone logs into the application. The user setting check insures fresh installs (as opposed to upgrades) don't trigger the restart.

private bool ApplicationUpdated()
{
    return ApplicationDeployment.IsNetworkDeployed && ApplicationDeployment.CurrentDeployment.IsFirstRun && userSettingsService.LastOnline != default(DateTime);
}
Community
  • 1
  • 1
CamHart
  • 3,825
  • 7
  • 33
  • 69