Application Settings user settings storage directory

Application Settings user settings storage directory

am 04.04.2008 13:20:16 von Chris Crowther

Hi All,

I was looking to use user settings to store some, well, user settings,
but right now the directory used to store changes periodically and I
haven't been able to work out what causes it.

It's storing it in a path that follows the pattern:

\Local Settings\Application Data\RHD_Research_Limited\ Name>_Url_?????????\

Where the "??????" portion is what was changing and is a stream of,
seemingly, random alpha numeric data; I'm guessing it's actually a hash
of some kind.

The form looks a little odd to me; I'm not sure where the Url* portion
is coming from or why the spaces have been changed to underscores.
Normally I'd expect to see the base path look more like

\Local Settings\Application Data\RHD Research Limited\

The version portion I expect to change when the assembly version number
is bumped - as it does - which is fine because that's what
Properties.Settings.Default.Upgrade() is for. Problem is that doesn't
work if the application directory keeps changing as well; it can't find
the old settings to upgrade them, because they're obviously in a
different path - this is the real problem for me.

Anyone have idea what is causing the application name to get mangled the
way it is and - a little more importantly - how I can stop it? If I
can't get it to work properly I'm going to have to fall back to using
registry entries - it is a winforms app - which is no great hardship,
it's just moderately annoying.

--
Chris Crowther MBCS
C# Developer
RHD Research Ltd

RE: Application Settings user settings storage directory

am 07.04.2008 06:47:34 von stcheng

Hi Chris,

As for the ApplicationSettings in .NET 2.0(for higher) application, is use
the default "LocalFileSettingsProvider" which will use randomly generated
path (in User's LocalSettings temp dir) to store "User Scope" setting
items. Here are some article which also mentioned some about the file path
of the user scope settings:

#Using My.Settings in Visual Basic 2005
http://msdn2.microsoft.com/en-us/library/ms379611(VS.80).asp x

#Exploring Secrets of Persistent Application Settings
http://www.devx.com/dotnet/Article/33944/1954

I've also inspected the LocalFileSettingsProvider class, it seems it use a
internal class to generate the temp file path(and will vary between
multiple updates). So far if you need a predictable path for store such
settings, I think you may consider the following options:

1. Use Application Scope instead of User Scope so that the settings will be
stored in App.config file

2. Use custom provider for your application, here is a web article
mentioned creating custom settings provider:

#Creating a Custom Settings Provider
http://www.codeproject.com/KB/vb/CustomSettingsProvider.aspx

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/de fault.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx .
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.




--------------------
>Date: Fri, 04 Apr 2008 12:20:16 +0100
>From: Chris Crowther MBCS
>Organization: RHD Research Ltd
>User-Agent: Thunderbird 2.0.0.12 (Windows/20080213)
>MIME-Version: 1.0
>Subject: Application Settings user settings storage directory

>
>Hi All,
>
>I was looking to use user settings to store some, well, user settings,
>but right now the directory used to store changes periodically and I
>haven't been able to work out what causes it.
>
>It's storing it in a path that follows the pattern:
>
>\Local Settings\Application Data\RHD_Research_Limited\ >Name>_Url_?????????\
>
>Where the "??????" portion is what was changing and is a stream of,
>seemingly, random alpha numeric data; I'm guessing it's actually a hash
>of some kind.
>
>The form looks a little odd to me; I'm not sure where the Url* portion
>is coming from or why the spaces have been changed to underscores.
>Normally I'd expect to see the base path look more like
>
>\Local Settings\Application Data\RHD Research Limited\
>
>The version portion I expect to change when the assembly version number
>is bumped - as it does - which is fine because that's what
>Properties.Settings.Default.Upgrade() is for. Problem is that doesn't
>work if the application directory keeps changing as well; it can't find
>the old settings to upgrade them, because they're obviously in a
>different path - this is the real problem for me.
>
>Anyone have idea what is causing the application name to get mangled the
>way it is and - a little more importantly - how I can stop it? If I
>can't get it to work properly I'm going to have to fall back to using
>registry entries - it is a winforms app - which is no great hardship,
>it's just moderately annoying.
>
>--
>Chris Crowther MBCS
>C# Developer
>RHD Research Ltd
>

Re: Application Settings user settings storage directory

am 07.04.2008 12:41:17 von Chris Crowther

Steven Cheng [MSFT] wrote:

> As for the ApplicationSettings in .NET 2.0(for higher) application, is use
> the default "LocalFileSettingsProvider" which will use randomly generated
> path (in User's LocalSettings temp dir) to store "User Scope" setting
> items. Here are some article which also mentioned some about the file path
> of the user scope settings:

Looking through http://blogs.msdn.com/rprabhu/articles/433979.aspx,
linked to from the second of those URLs, it seems the url_xxxx portion
of the file path is generated from the AppDomain evidence.

Taking a look at the Evidence info in the MSDN docs and checking the
values during runtime, the Url is the location of the executable file on
the disk, which changes any time we bump the version number.

> 1. Use Application Scope instead of User Scope so that the settings will be
> stored in App.config file

The problem with application scope is the settings will be RO - if I
understand it correctly - whereas these values need to be RW.

> 2. Use custom provider for your application, here is a web article
> mentioned creating custom settings provider:

I shall take a look at that, thanks.

> Steven Cheng

--
Chris Crowther MBCS
C# Developer
RHD Research Ltd

Re: Application Settings user settings storage directory

am 08.04.2008 05:15:28 von stcheng

Thanks for your reply Chris,

Yes, currently Application scope items doesn't provide existing means to
edit it. I found someone else provide some custom approach for editing
Application Scope setting items. Here is one posted by a MS engineer:

#Changing application settings programmatically in .NET Framework 2.0
http://blogs.msdn.com/mosharaf/archive/2007/01/19/changing-a pplication-setti
ngs-programmatically-in-net-framework-2-0.aspx

Hope this also helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/de fault.aspx#notif
ications.

This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
>Date: Mon, 07 Apr 2008 11:41:17 +0100
>From: Chris Crowther MBCS
>Organization: RHD Research Ltd
>Subject: Re: Application Settings user settings storage directory

>
>Steven Cheng [MSFT] wrote:
>
>> As for the ApplicationSettings in .NET 2.0(for higher) application, is
use
>> the default "LocalFileSettingsProvider" which will use randomly
generated
>> path (in User's LocalSettings temp dir) to store "User Scope" setting
>> items. Here are some article which also mentioned some about the file
path
>> of the user scope settings:
>
>Looking through http://blogs.msdn.com/rprabhu/articles/433979.aspx,
>linked to from the second of those URLs, it seems the url_xxxx portion
>of the file path is generated from the AppDomain evidence.
>
>Taking a look at the Evidence info in the MSDN docs and checking the
>values during runtime, the Url is the location of the executable file on
>the disk, which changes any time we bump the version number.
>
>> 1. Use Application Scope instead of User Scope so that the settings will
be
>> stored in App.config file
>
>The problem with application scope is the settings will be RO - if I
>understand it correctly - whereas these values need to be RW.
>
>> 2. Use custom provider for your application, here is a web article
>> mentioned creating custom settings provider:
>
>I shall take a look at that, thanks.
>
>> Steven Cheng
>
>--
>Chris Crowther MBCS
>C# Developer
>RHD Research Ltd
>

Re: Application Settings user settings storage directory

am 09.04.2008 10:20:41 von Chris Crowther

Steven Cheng [MSFT] wrote:

> Yes, currently Application scope items doesn't provide existing means to
> edit it. I found someone else provide some custom approach for editing
> Application Scope setting items. Here is one posted by a MS engineer:

I went with the custom settings provider, which seems to be working well
as a solution.

Thanks for the pointers :)

> Steven Cheng

--
Chris Crowther MBCS
C# Developer
RHD Research Ltd

Re: Application Settings user settings storage directory

am 09.04.2008 11:02:26 von stcheng

You're welcome :)

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

--------------------
>Date: Wed, 09 Apr 2008 09:20:41 +0100
>From: Chris Crowther MBCS
>Organization: RHD Research Ltd
>User-Agent: Thunderbird 2.0.0.12 (Windows/20080213)
>MIME-Version: 1.0
>Subject: Re: Application Settings user settings storage directory

>
>Steven Cheng [MSFT] wrote:
>
>> Yes, currently Application scope items doesn't provide existing means to
>> edit it. I found someone else provide some custom approach for editing
>> Application Scope setting items. Here is one posted by a MS engineer:
>
>I went with the custom settings provider, which seems to be working well
> as a solution.
>
>Thanks for the pointers :)
>
>> Steven Cheng
>
>--
>Chris Crowther MBCS
>C# Developer
>RHD Research Ltd
>