Link to home
Start Free TrialLog in
Avatar of Sancler
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.

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

Open in new window


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
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

it should be in a file somewhere under C:\Documents and Settings\UserName\Local Settings\Application Data
Avatar of Sancler
Sancler

ASKER

Sorry, should have said, this is on Windows 7.  So the equivalent, I think, would be C:\Users\Roger\AppData\Local\CSAccts or C:\Program Files (x86)\CSAccts (which is where the database resides - for the moment) or C:\Users\Roger\AppData\Local\VirtualStore\Program 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

Avatar of Sancler

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()...
Avatar of Sancler

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
Avatar of Sancler

ASKER

Found it.  Here's the path

C:\Users\Roger\AppData\Local\Hewlett-Packard_Company\csaccts.vshost.exe_Url_mmmu432yfqm1qjpaodxqavxl3icrudij\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
ASKER CERTIFIED SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Sancler

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\Local\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