Can't make ApplicationScopedSettingAttribute work at all

G

Guest

In the following MSDN documentation:

http://msdn2.microsoft.com/en-us/library/system.configuration.applicationsettingsbase(VS.80).aspx

there is an example of using ApplicationSettingsBase. I implemented the code
and it works as expected. However, I want application scoped settings, so I
changed UserScopedSetting to ApplicationScopedSetting. Now, it doesn't work
at all. No app.exe.config file is created and, of course, the settings are
not restored when the app is started subsequently.

What additional steps are required to use
ApplicationScopedSettingAttributes? Thanks!
 
G

Gary Chang[MSFT]

Hi Mountain,

That sample code is target at the UserScopedSettings. To use the
ApplicationScopedSettings you can manually add an app.config file (and its
values) to your project or add the application scoped values in your
project properties' setting's page.

But the application-scoped settings are read-only, in the case of the
default LocalFileSettingsProvider is used(e.g. local app.config file). So
the approach which that sample code used could not create and update the
application-scoped settings in the run-time.

Thanks!

Best regards,

Gary Chang
Microsoft Community Support
======================================================
PLEASE NOTE the newsgroup SECURE CODE and PASSWORD will be updated at 9:00
AM PST, February 14, 2006. Please complete a re-registration process by
entering the secure code mmpng06 when prompted. Once you have entered the
secure code mmpng06, you will be able to update your profile and access the
partner newsgroups.
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
G

Guest

Thank you for the reply. I need some further clarification. An example
showing how to use the ApplicationScopedSettings attribute would be helpful.

And my specific questions are:

If I manually add an app.config file as you suggest, I assume my app.config
sections must conform to a standard structure. Where is that structure
defined? (An example would be helpful.)

Are these the only differences between using ApplicationScopedSettings and
UserScopedSettings:
1. I must add an app.config file to my project.
2. I must manually define the application scoped settings in the app.config
file.
3. application scoped settings are read only.

It seems to me that there is more to it. I would guess that I also have to
implement all the code that reads the application scoped settings in the
app.config file and parses the text/XML into the appropriate .NET data types
(as well as handling all errors in the parsing, etc.). If I am right on this
point, then I can see no benefit from using the new ApplicationSettingsBase
with application scoped settings because it doesn't reduce the amount of work
to implement such settings. Please tell me I am wrong on this last point.

Regards,
Mountain
 
G

Gary Chang[MSFT]

Hi,
If I manually add an app.config file as you suggest, I assume
my app.configsections must conform to a standard structure.
Where is that structure defined? (An example would be helpful.)

You can use the VS2005 IDE's wizard to create a standard app.config. Just
right click your project node in the Solution Explorer and select
Properties, in the project's property sheet window select the "Settings"
tab, then you can add your application settings value in that tab and
VS2005 will create a corresponding app.config file automatically.
Are these the only differences between using ApplicationScopedSettings
and UserScopedSettings:
...

The main difference between them is the scope level they specified, it is
not necessary to use an app.config file for the ApplicationScopedSettings.
But it is still a general convention to use an app.config file just as in
..NET 1.1.

For the issue about the benefit from using the new ApplicationSettingsBase
with application scoped settings, the ApplicationSettingsBase class could
also works for the ApplicationScopedSettings, but those
ApplicationScopedSettings would not be updated in the run time in most
cases.

Thanks for your understanding.

Best regards,

Gary Chang
Microsoft Community Support
======================================================
PLEASE NOTE the newsgroup SECURE CODE and PASSWORD will be updated at 9:00
AM PST, February 14, 2006. Please complete a re-registration process by
entering the secure code mmpng06 when prompted. Once you have entered the
secure code mmpng06, you will be able to update your profile and access the
partner newsgroups.
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
G

Guest

The problem with your suggestion to "use the VS2005 IDE's wizard to create a
standard app.config." is that this method does not support using complex
types that are defined in the current assembly.

I am super frustrated that all these new .NET 2.0 configuration tools still
come up short. I'm left using the old .NET 1.1 approaches in most cases where
I need some relationships between elements defined in the configuration.

I would hope that there is something in the .NET 2.0 configuration that
would support what I want to do, but do far it seems this is just not the
case. These new tools only help in the simple situations. I thought MS was
committed to making sure its "easy-to-use" features would also apply to
enterprise level development. What happened to that commitment in the area of
configuration?

"Gary Chang[MSFT]" said:
Hi,
If I manually add an app.config file as you suggest, I assume
my app.configsections must conform to a standard structure.
Where is that structure defined? (An example would be helpful.)

You can use the VS2005 IDE's wizard to create a standard app.config. Just
right click your project node in the Solution Explorer and select
Properties, in the project's property sheet window select the "Settings"
tab, then you can add your application settings value in that tab and
VS2005 will create a corresponding app.config file automatically.
Are these the only differences between using ApplicationScopedSettings
and UserScopedSettings:
...

The main difference between them is the scope level they specified, it is
not necessary to use an app.config file for the ApplicationScopedSettings.
But it is still a general convention to use an app.config file just as in
.NET 1.1.

For the issue about the benefit from using the new ApplicationSettingsBase
with application scoped settings, the ApplicationSettingsBase class could
also works for the ApplicationScopedSettings, but those
ApplicationScopedSettings would not be updated in the run time in most
cases.

Thanks for your understanding.

Best regards,

Gary Chang
Microsoft Community Support
======================================================
PLEASE NOTE the newsgroup SECURE CODE and PASSWORD will be updated at 9:00
AM PST, February 14, 2006. Please complete a re-registration process by
entering the secure code mmpng06 when prompted. Once you have entered the
secure code mmpng06, you will be able to update your profile and access the
partner newsgroups.
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
G

Gary Chang[MSFT]

Hi,

I apologize for any inconvenience this may cause you. I will forward this
issue to our product team to review it. Hopefully we can find some way to
improve it in our next version product. Meantime, I highly suggest you can
submit this feedback to our product feedback center, our development team
may communicate with you directly on the issue there:

http://lab.msdn.microsoft.com/productfeedback/default.aspx

Your feedback and concerns are of great value to us and will help in
creating products that better meet your needs.

Thanks for your understanding!

Best regards,

Gary Chang
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.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top