Auto Increment Version resets application settings  
Author Message
Joel Harris





PostPosted: Visual C# General, Auto Increment Version resets application settings Top

I recently set my application to auto increment the version number when building by changing

[assembly: AssemblyVersion("1.0.0.0")]

to

[assembly: AssemblyVersion("1.0.0.*")]

in AssemblyInfo.cs. Now whenever I build my application I have to enter my settings (Properties.Settings.Default) again. How do I decouple the settings from the version in order to retain settings between builds

Thanks



Visual C#15  
 
 
Dan Dittenhafer





PostPosted: Visual C# General, Auto Increment Version resets application settings Top

Hi Joel,

We had the same problem a while back. We solved it by calling Upgrade on the ApplicationSettings derived class as in the following:

MyAppSettings settings = new MyAppSettings();

if (settings.CallUpgrade)

{

settings.Upgrade();

settings.CallUpgrade = false;

settings.Save();

}

The "CallUpgrade" property is one of our application settings that defaults to true so it will invoke the Upgrade call when the defaults are reinstated.


 
 
Dan Dittenhafer





PostPosted: Visual C# General, Auto Increment Version resets application settings Top

Alternatively, you could code a call to the GetPreviousVersion method of the ApplicationSettingsBase derived class to retrieve individual setting values from the previous version of the application.

http://msdn2.microsoft.com/en-gb/library/system.configuration.applicationsettingsbase.getpreviousversion.aspx


 
 
Joel Harris





PostPosted: Visual C# General, Auto Increment Version resets application settings Top

Dan,

Thanks for the response. I appreciate your help.