我的设置不起作用 [英] My.Settings not working

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

问题描述

我正在尝试首次使用My.Settings.如果我同步"设置,然后运行应用程序,则默认设置在那里.

如果我关闭该应用程序并再次运行,则所有设置都消失了.关于可能是什么问题的任何想法? (如果重要的话,我正在IDE中运行该应用程序)


噢,哇!真是n00b :(我的工作很长时间复制/粘贴错误.我有2个设置,它们之间有1个字母的不同.这是将Abool中的值保存到BBool中,而不是Abool中保存到Abool中.因为我将msgbox放在各处以跟踪值更改的位置,所以答案的确最终解决了该问题:P

I am attempting to use the My.Settings for the first time. If i "Synchronize" the settings and then run the app, the default settings are there.

If i close the app and run it again all the settings are gone. Any ideas on what could be the problem? (i am running the app in the IDE if that matters)


OH WOW! What a n00b :( Big time copy/paste error on my part. I have 2 settings that have 1 letter different between them. It was saving the value from Abool into BBool instead of Abool into Abool. SO sorry for wasting your time but your answers did ultimately fix the issue since i put msgbox everywhere to track where the value changed :P

推荐答案

如果您不更改设置,该怎么办?是否仍然存在?我还是不太确定您的问题是什么.如果我创建一个名为"MySetting"的设置,该设置是一个字符串,并且用户范围的值为"DefaultValue",则下面的代码将在第一个显示"DefaultValue"一次运行该应用程序,第二次运行该应用程序已更改":
If you aren''t changing the settings, what is there to persist? I''m still not quite sure what your problem is. If I create a setting called "MySetting" that is a string and has user scope with the value of "DefaultValue", the following code will display "DefaultValue" the first time I run the application and "Changed" the second time I run it:
Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles MyBase.Load
        MsgBox(My.Settings.MySetting)
        My.Settings.MySetting = "Changed"
        My.Settings.Save()
    End Sub
End Class


因此,您的问题是试图更新代码中的设置,但是下次运行应用程序时,这些更改不存在(它们将还原为默认值)?

您使用什么代码同步"设置(您应该使用保存"方法)?设置的范围是用户"还是应用程序"?我认为应用程序作用域设置没有保存(对此可能是错误的),尽管我认为您无论如何都不能分配给它们(应该产生编译错误).
So, your problem is that you are trying to update your settings in code, but the next time you run your application those changes are not there (they are reverted to the default values)?

What code are you using to "Synchronize" the settings (you should be using the "Save" method)? Is the scope of the settings "User" or "Application"? I think application scope settings do not get saved (could be wrong about that), although I don''t think you can assign to them anyway (should produce a compile error).


设置设置为用户范围.要重置设置,我正在使用IDE中的同步"按钮.我只是想让设置保持在应用运行之间.在这一点上,我没有代码来修改设置.使用IDE时,设置在两次运行之间是否保持不变?
The settings are set to User scope. To reset the settings i am using the Synchronize button in the IDE. I am just trying to have the settings stay between app runs. At this point i have no code to modify the settings. Do the settings persist between runs while using the IDE?


这篇关于我的设置不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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