cygnusx

When i add setting with type Hashtable in project settings(Project - Properties - Settings) i cannot add anything to the Hashtable.I mean i can't add keys to the Hashtable from the small button in the "value" column,the buttons in the opened window are not active.Therefore obviosly i cannot add keys to the hashtable in the code designer because the Hashtable doesn't have a value...Is there something that i do not understand


Re: Visual C# IDE Adding Hashtable setting to project settings doesn't work

OmegaMan

Questions:

  1. Does this happen on other projects on just this one
  2. What type of project is it Try creating a test winform application and see if the same happens.
  3. What version of Visual Studio are you using Have you installed SP1 for 2005





Re: Visual C# IDE Adding Hashtable setting to project settings doesn't work

cygnusx

1.Yes,this happens on other projects too
2.It's Windows application
3.VS 2005 Express Edition,and no i don't have SP1 installed




Re: Visual C# IDE Adding Hashtable setting to project settings doesn't work

BabyFace Jay

Hi, I encountered this before too. I duno if there is a reason for this but I guess you could check the Hashtable for the settings you want during the start of application or whenever you need them, and if it does not have the preset settings, you could add them into the hashtable with the defaults at that point.





Re: Visual C# IDE Adding Hashtable setting to project settings doesn't work

OmegaMan

Does this happen on a new project Are the other projects in source control and the files needed to be written are read only on your drive





Re: Visual C# IDE Adding Hashtable setting to project settings doesn't work

cygnusx

That happens on all projects.And that what i want to do has nothing to do with files on the hard drive.I'm just saying that i cannot add keys to the Hashtable in the Project - Properties - Settings.I tried with ArrayList for example and it works,i can add objects to it.The "Add" button is active,but in the case with Hashtable isn't.




Re: Visual C# IDE Adding Hashtable setting to project settings doesn't work

OmegaMan

My bad...I see what you are driving at now. I tried adding a system.collection.hashtable and discovered the same issue. I even tried to add a hastable in the code to no avail. No documentation I found has no mention of this situation....





Re: Visual C# IDE Adding Hashtable setting to project settings doesn't work

ChunSheng Tang - MSFT

Hi,

Quoted from http://msdn2.microsoft.com/en-us/library/ms950721.aspx

Q: Why can't I serialize hashtables

A: The XmlSerializer cannot process classes implementing the IDictionary interface. This was partly due to schedule constraints and partly due to the fact that a hashtable does not have a counterpart in the XSD type system. The only solution is to implement a custom hashtable that does not implement the IDictionary interface.

The above comment indicates that the HashTable cannot be serialized to XML format. As we know that application settings are saved in XML format, this should be able to explain why you cannot add a setting of type HashTable.

Best Regards

Chunsheng Tang






Re: Visual C# IDE Adding Hashtable setting to project settings doesn't work

ChunSheng Tang - MSFT

Chunsheng Tang wrote:

As we know that application settings are saved in XML forma


The formator can be specified by SettingsSerializeAs Attribute. However there seems to be no way that you can change it for the default settings class in Settings.settings. A solution would be creating a new application settings class and custom it to use binary formator. You may refer to this thread:
http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=2177021&SiteID=1

Best Regards
Chunsheng Tang






Re: Visual C# IDE Adding Hashtable setting to project settings doesn't work

cygnusx

Yeah,but how to access the settings after that Obviosly i do not want to create new instance of the Settings class every time(as it is in example you gave) because i just want to save them to the disk and retrieve them next time when i start the application.For example the settings of a .Net application are accessed in this way Properties.Settings.Default...but how to access the settings in custom settings class Thanks in advance.




Re: Visual C# IDE Adding Hashtable setting to project settings doesn't work

Chunsheng Tang - MSFT

cygnusx wrote:
Yeah,but how to access the settings after that Obviosly i do not want to create new instance of the Settings class every time(as it is in example you gave) because i just want to save them to the disk and retrieve them next time when i start the application.For example the settings of a .Net application are accessed in this way Properties.Settings.Default...but how to access the settings in custom settings class Thanks in advance.


Please take a look at Settings.Designer.cs and build a helper class yourself.