473,698 Members | 2,434 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Settings.settin gs and custom types

I am trying to use a custom type inside settings.settin gs. 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.settin gs file?

Thanks,
--Rob.

Apr 26 '07 #1
3 4392
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**@discussio ns.microsoft.co mwrote in message
news:F9******** *************** ***********@mic rosoft.com...
>I am trying to use a custom type inside settings.settin gs. 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.settin gs 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.settin gs, so in
the settings designer I chose "MyApp.MyCl ass" 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.Sett ings.Default.My Class.firstVari able, 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**@discussio ns.microsoft.co mwrote in message
news:F9******** *************** ***********@mic rosoft.com...
I am trying to use a custom type inside settings.settin gs. 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.settin gs 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**@discussio ns.microsoft.co mwrote in message
news:C0******** *************** ***********@mic rosoft.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.settin gs, so
in
the settings designer I chose "MyApp.MyCl ass" 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.Sett ings.Default.My Class.firstVari able, 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**@discussio ns.microsoft.co mwrote in message
news:F9******* *************** ************@mi crosoft.com...
>I am trying to use a custom type inside settings.settin gs. 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.settin gs 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
12082
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 likelihood of CRM success from less than 20 percent to 60 percent. WHITEPAPER :
4
8724
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 that I am creating a setting called Connections of type System.Collections.ArrayList using the Properties designer in VS.
1
5024
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 get null returned. MyProperties prop = Properties.Settings.Default.MyProp Assuming prop is null because MyProperties is not a value type I changed MyProperties from a class to a struct. Unfortunately, settings editor does not allow me to add a...
1
2973
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 problem is I can fill in the 'type' of the setting as my custom class, but if I try to save the settings - calling the My.Settings.Save() - then reload the settings at a later time with the My.Settings.Reload() - the data in my custom class is not...
3
1527
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 example a collection of city/state/country's e.g.
3
2345
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 System.Collections.ArrayList type, but I'm unable to determine what to type into the Value feild for a default setting so the property will not be null at runtime...
1
3420
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 of my settings that I created show up fine in intellisense, but when I execute the app, I get... ****************************** Compilation Error
0
1730
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 Properties.Settings file in this way for normal types (ints, chars etc) but I am struggling to get it to work for my own types. The type I want to use in the Settings file is a custom implementation of the generic Dictionary class using a string and another...
11
10138
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 seen erratic results. I am aware of one known defect where user classes do not show up in the list of types on the Property/Settings page in the visual designer and I am wondering if I am encountering some other peculiar issue, or if there are...
0
8675
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9160
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8897
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8862
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4370
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3050
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2331
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.