Finding mysterious Application Settings

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

When I run a particular application I've been working on for a while, it
somehow finds a value for the Application Setting
"Test.Properties.Settings.Default.ProjectPath", but I can't see where it is
acquiring the value! I have been through all of the project's Properties,
and read through every app.config on my entire computer and can't find the
value it's getting during runtime.

Mysteriously, when I step through the application in debug mode, that
Application Setting never does acquire a value. Only when I run the
(debug-compiled) executable outside of the debugger does it find an old value.

Any ideas on how this can happen, and how I can find an purge the rogue
value from my computer?
 
Dave said:
When I run a particular application I've been working on for a while, it
somehow finds a value for the Application Setting
"Test.Properties.Settings.Default.ProjectPath", but I can't see where it is
acquiring the value! I have been through all of the project's Properties,
and read through every app.config on my entire computer and can't find the
value it's getting during runtime.

Mysteriously, when I step through the application in debug mode, that
Application Setting never does acquire a value. Only when I run the
(debug-compiled) executable outside of the debugger does it find an old value.

Any ideas on how this can happen, and how I can find an purge the rogue
value from my computer?

I presume you're using VS2005? In that case, in the solution explorer,
expand the node of your project that says "Properties", then expand
"Settings.settings". Under that open the Settings.Designer.cs. You
should see your properties similar to this:


[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]

[global::System.Configuration.DefaultSettingValueAttribute("DefaultValue")]
public string SqlInstance {
get {
return ((string)(this["SqlInstance"]));
}
}

The default value is in the DefaultSettingValueAttribute.

Hope this helps
 
Yes, this is a VS2005 project and application. The
DefaultSettingValueAttribute in the Settings is "", so it's not picking up
the value there. I.e.,

[global::System.Configuration.DefaultSettingValueAttribute("")]
public string ProjectPath {
 
Hi Dave,

Thank you for posting.

Is the ProjectPath a user-scoped setting in your project?

The default value of a user-scoped setting is stored in the application
config file which is located in the same path of the exe file. However, if
you have changed the value of the user-scoped setting at run-time and saved
the new value back to the disk, the new value is stored in a user config
file named user.config. The user config file is located in the local
settings path of the current user. For example, the path may look like this:
"C:\Documents and Settings\Administrator\Local Settings\Application
Data\MS\MyTestProjectName \1.0.0.0".

Once there's a value in the user config file, this value is retrieved as
the user-scoped setting's value.

Please check the user config file of your application on your machine. I
think you may find the value of the ProjectPath setting there.

I look forward to your reply.


Sincerely,
Linda Liu
Microsoft Online Community Support

====================================================
When responding to posts,please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
====================================================
 
Sounds promising -- the Settings.settings in the project do mark all of the
setting names as Scope "User".

But there is not a single user.config file under my entire "C:\Documents and
Settings" directory hierarchy (according to Windows Search). And in any case
I could not find a folder under there that resembles my project/application
name.

Is there someplace else the user settings could be hiding?
 
Hi Dave,

Thanks for your update and response.

A user.config file is created at run time when the user running the
application changes the value of any user setting. If you never change the
value of any user setting, there won't be a user.config file.

The default values of all the application settings of a program are stored
in the app.config file which is located under the directory of the project.
And this app.config file will be exported to an exe.config file in the
project's output path. If the name of your project is SampleProj, the name
of the config file is SampleProj.exe.config.

I recommend you to check this app.config file or exe.config file in your
project.

If you have anything unclear, please don't hesitate to let me know.


Sincerely,
Linda Liu
Microsoft Online Community Support

====================================================
When responding to posts,please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
====================================================
 
OK, I thought your answers would cover anything, but I still cannot find some
settings.

To summarize your earlier answers, an application setting must appear in one
of the following places:

1. app.config, in the root of the project directory.
2. user.config, somewhere in the Documents and Settings folders
3. {App}.exe.config, where {App}.exe is the compiled application

I have searched every file meeting the above criteria and still cannot find
the value being assigned to one of the application settings in my program!

Would appreciate any other hints as to where or how I might find that!
 
Problem solved. Turns out the settings I was looking for WERE under the
Documents and Settings hierarchy; not sure why the Windows Search command
couldn't find them. For the benefit of posterity, the way I finally fixed
this: Open the project's Properties/Settings.settings in Visual Studio, then
click on the Synchronize button in the top left of that tab.

Doing so gave me a warning that referenced the exact location of the rogue
file that had been storing the values the application had been using, and
also gave me the benefit of clearing those accumulated settings!
 
Could be that the rouge file was in a hidden directory. I don't think
the windows search will go into hidden directories by default, you have
to tell it to do so under advanced options (I also turn on system
folders when searching for specific files to make sure I get
everything).
 
Hi Dave,

Thank you for your update.

It seems that there're several possible places for .NET to store the
user.config file under the Documents and Settings hierarchy. Your method to
find out the location of the user.config file is very useful.

If you have any other questions, please don't hesitate to contact us.

Have a nice day!

Sincerely,
Linda Liu
Microsoft Online Community Support

====================================================
When responding to posts,please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
====================================================
 
Back
Top