Sancler
asked on
Where are VB.NET settings held?
I have a Visual Basic 2010 Express project that I'm developing. It includes an option to change the font in some display grids. Here's the code.
It works, there's no problem from that point of view. Not only is the change in font reflected while the project is running but it is also retained from one run to the next, including over a full system shutdown.
But what I cannot work out is where that selection is stored. If I look at the settings tab in Project Properties it never changes: it is always set at Microsoft Sans Serif, 8.25pt, even when the font actually being used is, for instance, Comic Sans MS, Bold Oblique, 10pt. I've inspected all the settings and config files I can find in the project directory and all sub-directories, but can find nothing apart from Microsoft Sans Serif, 8.25pt. But the changed value must be being stored somewhere or it wouldn't work.
Where is it?
Roger
Private Sub btnFont_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFont.Click
FontPicker.Font = My.Settings.GridFont
Dim result As DialogResult = FontPicker.ShowDialog
If result = DialogResult.OK Then
Dim newfont As Font = FontPicker.Font
My.Settings.GridFont = newfont
End If
My.Settings.Save()
lblFont.Font = My.Settings.GridFont
End Sub
It works, there's no problem from that point of view. Not only is the change in font reflected while the project is running but it is also retained from one run to the next, including over a full system shutdown.
But what I cannot work out is where that selection is stored. If I look at the settings tab in Project Properties it never changes: it is always set at Microsoft Sans Serif, 8.25pt, even when the font actually being used is, for instance, Comic Sans MS, Bold Oblique, 10pt. I've inspected all the settings and config files I can find in the project directory and all sub-directories, but can find nothing apart from Microsoft Sans Serif, 8.25pt. But the changed value must be being stored somewhere or it wouldn't work.
Where is it?
Roger
it should be in a file somewhere under C:\Documents and Settings\UserName\Local Settings\Application Data
ASKER
Sorry, should have said, this is on Windows 7. So the equivalent, I think, would be C:\Users\Roger\AppData\Loc al\CSAccts or C:\Program Files (x86)\CSAccts (which is where the database resides - for the moment) or C:\Users\Roger\AppData\Loc al\Virtual Store\Prog ram Files (x86)\CSAccts. Nothing in any of those.
But the application hasn't been published yet. I'm running it from the VBExpress IDE. I've run it in both Debug and Release modes. So I've been looking in the project directory bin/Debug and bin/Release folders and obj/x86/Debug and obj/x86/Release folders. Plenty of files to inspect in there but all that I recognise as possible candidates (.config and .settings) show the Microsoft Sans Serif, 8.25pt even when the font that will in fact be used - that is, what the progam reads from "My.Settings.GridFont" in line 2 of the code above - has been changed to something different.
Roger
But the application hasn't been published yet. I'm running it from the VBExpress IDE. I've run it in both Debug and Release modes. So I've been looking in the project directory bin/Debug and bin/Release folders and obj/x86/Debug and obj/x86/Release folders. Plenty of files to inspect in there but all that I recognise as possible candidates (.config and .settings) show the Microsoft Sans Serif, 8.25pt even when the font that will in fact be used - that is, what the progam reads from "My.Settings.GridFont" in line 2 of the code above - has been changed to something different.
Roger
ASKER
Oops. Change "/" to "\" in those paths above.
when I run my demo, I see this folder C:\Users\Eric Moreau\AppData\Local\Demo which contains some subfolder to ultimately find user.config
I don't see where you are calling My.Settings.Save()...
ASKER
emoreau
No, there's no equivalent to that. There is a folder with the name of the project. But it has no sub-folders and no user.config file in it.
TheLearnedOne
How about line 8?
I'm going to do a system wide search for all user.config files and see if I can find it that way. It'll take ages, but I'll report back.
Roger
No, there's no equivalent to that. There is a folder with the name of the project. But it has no sub-folders and no user.config file in it.
TheLearnedOne
How about line 8?
I'm going to do a system wide search for all user.config files and see if I can find it that way. It'll take ages, but I'll report back.
Roger
ASKER
Found it. Here's the path
C:\Users\Roger\AppData\Loc al\Hewlett -Packard_C ompany\csa ccts.vshos t.exe_Url_ mmmu432yfq m1qjpaodxq avxl3icrud ij\1.0.0.0
I can think of no sensible reason why it should be in a "Hewlett-Packard_Company" folder. I'm using an HP desktop machine, but ...
Any ideas?
Roger
C:\Users\Roger\AppData\Loc
I can think of no sensible reason why it should be in a "Hewlett-Packard_Company" folder. I'm using an HP desktop machine, but ...
Any ideas?
Roger
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
csaccts
But I've now discovered the root cause. I looked at the Assembly Information in the Application tab in the Project Properties and discovered that Company: was set to Hewlett-Packard_Company. How that happened, Heaven only knows. But I got rid of that, re-ran, and now I am getting a user.config file in a sub-folder of C:\Users\Roger\AppData\Loc al\CSAccts with the changed font name, etc. in it.
So, it's sorted (not that it wasn't working, in the first place, but not understanding what was going on was bugging me).
Points to emoreau for nudging me towards looking for all user.config files.
Thanks
But I've now discovered the root cause. I looked at the Assembly Information in the Application tab in the Project Properties and discovered that Company: was set to Hewlett-Packard_Company. How that happened, Heaven only knows. But I got rid of that, re-ran, and now I am getting a user.config file in a sub-folder of C:\Users\Roger\AppData\Loc
So, it's sorted (not that it wasn't working, in the first place, but not understanding what was going on was bugging me).
Points to emoreau for nudging me towards looking for all user.config files.
Thanks