473,396 Members | 1,683 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Settings.settings and custom types

I am trying to use a custom type inside settings.settings. When I create my
class, I am able to add it in as the type and the value ends up showing as
XML data. If I change any of the values in my class, the values do not
update the settings file. Can anyone provide any insight and/or sample code
on how to use a user defined class as a valid and usable type in the
settings.settings file?

Thanks,
--Rob.

Apr 26 '07 #1
3 4363
It must be a User-scoped Setting, and you must save the Settings prior to
closing the app.

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

"Rob L" <Ro**@discussions.microsoft.comwrote in message
news:F9**********************************@microsof t.com...
>I am trying to use a custom type inside settings.settings. When I create
my
class, I am able to add it in as the type and the value ends up showing as
XML data. If I change any of the values in my class, the values do not
update the settings file. Can anyone provide any insight and/or sample
code
on how to use a user defined class as a valid and usable type in the
settings.settings file?

Thanks,
--Rob.

Apr 27 '07 #2
Kevin:

Thanks for the response. I have the setting scoped as user, and I do call
the save method.

What I am looking to do is, lets say I have a class like this:

class MyClass
{
public int firstVariable;
public int secondVariable;
public string someString;
}

and I want to store the values of this class in the settings.settings, so in
the settings designer I chose "MyApp.MyClass" as the type with the scope of
user and the tool generated a block of XML in the app.config file. I am able
to get the settings by reading
Properties.Settings.Default.MyClass.firstVariable, etc., however, I am unable
to update and save the values back to the config file.

Any ideas?

Thanks,
--Rob.

"Kevin Spencer" wrote:
It must be a User-scoped Setting, and you must save the Settings prior to
closing the app.

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

"Rob L" <Ro**@discussions.microsoft.comwrote in message
news:F9**********************************@microsof t.com...
I am trying to use a custom type inside settings.settings. When I create
my
class, I am able to add it in as the type and the value ends up showing as
XML data. If I change any of the values in my class, the values do not
update the settings file. Can anyone provide any insight and/or sample
code
on how to use a user defined class as a valid and usable type in the
settings.settings file?

Thanks,
--Rob.


Apr 27 '07 #3
Are you assigning the Settings class instance to a variable, and saving that
at the end, or creating another instance and saving that at the end? If you
reference the actual instance in the Settings, when you save it should be
serialized back.

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

"Rob L" <Ro**@discussions.microsoft.comwrote in message
news:C0**********************************@microsof t.com...
Kevin:

Thanks for the response. I have the setting scoped as user, and I do call
the save method.

What I am looking to do is, lets say I have a class like this:

class MyClass
{
public int firstVariable;
public int secondVariable;
public string someString;
}

and I want to store the values of this class in the settings.settings, so
in
the settings designer I chose "MyApp.MyClass" as the type with the scope
of
user and the tool generated a block of XML in the app.config file. I am
able
to get the settings by reading
Properties.Settings.Default.MyClass.firstVariable, etc., however, I am
unable
to update and save the values back to the config file.

Any ideas?

Thanks,
--Rob.

"Kevin Spencer" wrote:
>It must be a User-scoped Setting, and you must save the Settings prior to
closing the app.

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

"Rob L" <Ro**@discussions.microsoft.comwrote in message
news:F9**********************************@microso ft.com...
>I am trying to use a custom type inside settings.settings. When I
create
my
class, I am able to add it in as the type and the value ends up showing
as
XML data. If I change any of the values in my class, the values do not
update the settings file. Can anyone provide any insight and/or sample
code
on how to use a user defined class as a valid and usable type in the
settings.settings file?

Thanks,
--Rob.



Apr 27 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: sonu | last post by:
I have following client side code which i have used in my asp.net project SummaryFeatured Resources from the IBM Business Values Solution Center WHITEPAPER : CRM Done Right Improve the...
4
by: eugenet | last post by:
Hello, I am writing a Windows Forms application using .NET Framework 2.0 and Visual Studio 2005. I would like to use Properties.Settings class to persist a collection of custom objects. For...
1
by: rob | last post by:
Using the settings editor I am trying to add a setting whose type is a custom type. In a first approach I tried a class marked as . But then when I try to get the property the way shown bellow I...
1
by: modi321 | last post by:
Everyone, I have a question on how to use persistant application settings with 2.0. I understand I can use defined types like ints, strings, and so on, but how about my own custom class? The...
3
by: Ivan Berg | last post by:
Hey everyone, hopefully this will have a simple answer. Using VS2005/.NET 2.0 Application settings. I have simple settings working fine, but I am trying to store more complex types now. For...
3
by: Michael Slattery | last post by:
Hello, I see quite a few questions, but no valid responses to the question... How do I store an ArrayList of items in a Properties file via the GUI? I am able to select the...
1
by: JamminJimE | last post by:
I dunno if it's too late at night to be coding without the caffeine, but I am sure trying. I have a web app that I am working on and am trying to set some of the custom My.Settings values. Each...
0
by: =?Utf-8?B?RnV0cm9uaWNzIERldmVsb3Blcg==?= | last post by:
I am trying to store a collection of custom types in a Properties.Settings file which I will be updating at run time and saving on exit of the program. I understand how to use the...
11
by: =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= | last post by:
I have worked with application settings in VS2005 and C# for awhile, but usually with standard types. I have been trying to store a custom container/class/type in an application setting and I have...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.