Güncelleme: Aşağıdakilerin WP7 uygulamaları için geçerli olup olmadığından emin değilim - her ihtimale karşı burada bırakacağım. Bunu normal uygulamalar için denedim.
Eski ayarlar dosyasını "yükseltmeniz" gerekecektir.
Ayrıca, bunu yapmanız gerektiğinde (yani, yalnızca yeni bir sürüm yüklendiğinde) bilmeniz gerekir.
Ayarları yeni sürüme geçirmeniz gerektiğini öğrenmek için, ayarlarınıza (demek) NeedSettingsUpgrade adlı bir boolean ekleyin ve bunları true olarak ayarlayın.
Sonra Main() başlangıcında yakın bir yerde aşağıdaki işlevi çağırır:
/// <summary>Upgrades the application settings, if required.</summary>
private static void upgradeApplicationSettingsIfNecessary()
{
// Application settings are stored in a subfolder named after the full #.#.#.# version number of the program. This means that when a new version of the program is installed, the old settings will not be available.
// Fortunately, there's a method called Upgrade() that you can call to upgrade the settings from the old to the new folder.
// We control when to do this by having a boolean setting called 'NeedSettingsUpgrade' which is defaulted to true. Therefore, the first time a new version of this program is run, it will have its default value of true.
// This will cause the code below to call "Upgrade()" which copies the old settings to the new.
// It then sets "NeedSettingsUpgrade" to false so the upgrade won't be done the next time.
if (Settings.Default.NeedSettingsUpgrade)
{
Settings.Default.Upgrade();
Settings.Default.NeedSettingsUpgrade = false;
}
}
Not: Elbette aksi ayarları kalıcı olmayacak değiştirmek, programınız çıkmadan önce Settings.Default.Save()
aramanız gerekmektedir.
Sorununuzla da ilgileniyorum. Uygulamamı test ederken benzer bir şey fark ettim. Visual Studio'dan çalıştırırken ve telefonu (emülatöre değil) hedeflerken, bazen veritabanını silip yeniden oluşturur, diğer zamanlarda veritabanını silmeden kodu günceller. – Dante