的ClickOnce和IsolatedStorage [英] ClickOnce and IsolatedStorage

查看:106
本文介绍了的ClickOnce和IsolatedStorage的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在WinForm应用程序发布使用ClickOnce在我们的内联网。我们存储个人preference在独立存储的GUI。所有作品pretty罚款:)

The Winform application is release with ClickOnce in our Intranet. We store personal preference for the GUI in the Isolated Storage. All works pretty fine :)

问题是,当我们的应用程序的新版本中,我们发布...所有preferences都将丢失!用户需要设置自己的preference遍地每个版本。

The problem is when we have a new version of the application, we publish... all preferences are lost! User need to setup their preference over and over each version.

有没有办法冻结整个应用程序而不是版本隔离?

Is there a way to freeze the isolation for the whole application instead of the version?

推荐答案

您需要使用的应用程序的范围,而不是的的范围,隔离存放。这可以通过使用 IsolatedStorageFileStream的重载的构造函数之一来完成。

You need to use application scoped, rather than domain scoped, isolated storage. This can be done by using one of IsolatedStorageFileStream's overloaded constructors.

例如:

using System.IO;
using System.IO.IsolatedStorage;
...

IsolatedStorageFile appScope = IsolatedStorageFile.GetUserStoreForApplication();    
using(IsolatedStorageFileStream fs = new IsolatedStorageFileStream("data.dat", FileMode.OpenOrCreate, appScope))
{
...

不过,现在你都会碰到这种code只有工作时,应用程序已通过ClickOnce的推出,因为这是唯一的一次应用范围的独立存储可用的问题。如果不通过ClickOnce的推出(如通过Visual Studio), GetUserStoreForApplication()会抛出异常。

周围的道路的这个的问题是确保 AppDomain.CurrentDomain.Activati​​onContext 不为空之前试图使用应用程序范围内的独立存储。

The way around this problem is to make sure AppDomain.CurrentDomain.ActivationContext is not null before trying to use application scoped isolated storage.

这篇关于的ClickOnce和IsolatedStorage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆