Visual Basic Development Bookmark and Share   
 Home > Visual Basic Language > My.Settings and Hashtable
 

My.Settings and Hashtable

Does someone have an example of using a hashtable datatype in VS2005 my.settings?

In the VS settings designer, the field, ScreenLayout is defined with a datatype of hashtable.

I created a test application to do this. see the following code:

My.Settings.ScreenLayout = New Hashtable

My.Settings.ScreenLayout.Add("one", "one in hash")

My.Settings.ScreenLayout.Add("two", "two in hash")

My.Settings.ScreenLayout.Add("three", "three in hash")

My.Settings.Save()

When I run the application the first time, I can access the values from the hashtable in my.settings. Yet when run the application the second time and examine my.settings.ScreenLayout, it is set to nothing.

Could someone explain the issue to me?

TIA

Fidence  Thursday, November 02, 2006 9:11 PM
SvenC  Thursday, November 02, 2006 10:17 PM

Hi,

if creating a type converter is a bit too heavy yet, you might try to keep with simpler data types, which can be used without extra work. Try to start storing settings as simple string. You might as well store semi structured data as strings with some separating characters like "one#one in hash#two#two in hash" and parse that string when you retrieve it from My.Settings. Actually that is what a type converter for ToString and FromString is about: represent object state as simple string content.

--
SvenC

SvenC  Friday, November 03, 2006 11:18 PM
SvenC  Thursday, November 02, 2006 10:17 PM

SvenC

I am still new with .net and so Johan's blog did not help my very much (there was no explaination of the code), but thank you for trying to help.

Fidence  Friday, November 03, 2006 8:17 PM

Hi,

if creating a type converter is a bit too heavy yet, you might try to keep with simpler data types, which can be used without extra work. Try to start storing settings as simple string. You might as well store semi structured data as strings with some separating characters like "one#one in hash#two#two in hash" and parse that string when you retrieve it from My.Settings. Actually that is what a type converter for ToString and FromString is about: represent object state as simple string content.

--
SvenC

SvenC  Friday, November 03, 2006 11:18 PM

SvenC,

Thank you for you help. That is what I am doing. I am now storing the settings in a string datatype. The data will be stored as XML in the my.settings.

Again, thanks!

Fidencio

Fidence  Monday, November 06, 2006 2:13 PM

You can use google to search for other answers

Custom Search

More Threads

• visual basic program
• Email from VB.NET(Urgent)
• Exception when adding relationship to detail boundsource.datamember
• Decrypt a file
• checking for a file type during upload
• Launch 'Add or Remove Programs'
• Microsoft EqualsBuilder Equivalent
• Addition
• Having problem to create ASP.NET web service
• Have an application get it's own checksum?