locked
Settings RRS feed

  • Question

  •  

    Ok maybe I'm doing this all wrong, but I'm realy having problems to create Settings for my application. And by Settings I mean the Settings tab you find in your Project Properties.

     

    Anyway, I wasn't able to find the Type Dictionary so I decided to use StringDictionary (Although I would still rather use Dictionary instead if anyone knows how...) When I now try to run my application I get an exception telling me it wasn't able to initialize the configuration system.

     

    I'm guessing this is because the StringDictionary can't get initialized, becaues when I use a StringList VisualStudio automaticly generates the folowing XML code for me to define an empty list:

     

    Code Snippet
    <?xml version="1.0" encoding="utf-16"?>
    <ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    </ArrayOfString>

     

     

    But this is not the case with the StringDictionary; what kind of initialization does that need?

     

    There are more strange things I noticed with Settings by the way. Like not being able to add any values to a Hashtable.

    Tuesday, February 12, 2008 6:50 PM

Answers

  • The settings technology is still supported in WPF, Windows Forms and even ASP.NET. Base on my understanding, we are unable to implement ourself data source in current version of .NET Framework.

     

    Best Regards,

    Wei Zhou

    Friday, February 15, 2008 10:10 AM

All replies

  • You should make sure that all elements you want to add to the directory collection should can be serializable. Furthermore, you may also need to implement TypeConverter to do this.

     

    Best Regards,

    Wei Zhou

    Thursday, February 14, 2008 5:14 AM
  •  

    Thank you for your reply.

     

    However, I am unable to create a Setting of type Dictionary and if I instead use StringDictionary I get the exception I showed above when I use the folowing code:

    Settings.Default.TreatedTenders

     

    This has nothing to do with values or anything, since my collection is empty and has no value.

    Thursday, February 14, 2008 7:48 AM
  • I think that the easiest way to do this is you can use two StringCollections to accomplish this. The first StringCollection you can used for storing keys, and the second StringCollection you can used for storing values.

     

    Best Regards,

    Wei Zhou

    Thursday, February 14, 2008 9:18 AM
  • Thanks, that could be a good work around.

     

    Does this mean that Settings in WPF are no longer supported or something? I mean, it should'nt be that hard to be able to implement a (String)Dictionary, right?

    • Proposed as answer by SavvyAl Saturday, December 11, 2010 9:58 PM
    Friday, February 15, 2008 7:55 AM
  • The settings technology is still supported in WPF, Windows Forms and even ASP.NET. Base on my understanding, we are unable to implement ourself data source in current version of .NET Framework.

     

    Best Regards,

    Wei Zhou

    Friday, February 15, 2008 10:10 AM