如何以编程方式坚持建设? [英] How to persist from build programmatically?

查看:85
本文介绍了如何以编程方式坚持建设?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够在发布之前以编程方式将某些信息加载到Properties.Settings.Default中,但是它不会持久存在.我该如何克服?

I want to be able to load some information programmatically into Properties.Settings.Default before I publish it, but it doesn't persist. How do I overcome that?

我有(作为测试):

private void button1_Click(object sender, EventArgs e)
{
    Properties.Settings.Default.Setting1 = "abc";
    Properties.Settings.Default.Save();
}

private void button2_Click(object sender, EventArgs e)
{
    Text = Properties.Settings.Default.Setting1;
}

我单击了button1,然后发布(带有clickonce),然后运行发布的应用程序并单击了button2. Text为空.

I clicked on button1, then published (with clickonce) and then run the published application and clicked on button2. The Text was empty.

如果不发布该应用程序,只需将其关闭并重新打开,然后单击button2 –我会得到"abc".

If don't publish the application, rather just close it and reopen it and click on button2 – I get "abc".

推荐答案

似乎问题在于作用域是用户".但是,如果范围是应用程序",则无法以编程方式进行更改.

It seems that the problem was that the scope was "user". But if the scope is "application" – it can't be changed programmatically.

因此似乎没有办法.坚持以编程方式进行构建,即.

So there seems not to be a way to do it. Persist from build programmatically, that is.

这篇关于如何以编程方式坚持建设?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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