I'm developing an extension for visual studio.
There I have an option page:
public class GeneralOptionsPage : DialogPage
{
[Category("General")]
[DisplayName("Foos")]
[Description("Bla Foo Bla")]
public string[] Foos { get; set; }
[Category("General")]
[DisplayName("Bar")]
[Description("Bar Foo Bar")]
public string Bar { get; set; }
}
The Bar
property works perfectly and is persisted.
The Foos
Property does also work (it even gives you a nice popup in the options page where you can enter one string per line), which means I can set it and also use it in my extension but it is not written to the registry/storage. When I close VS and open it again it's always empty.
Quote from MSDN:
The default implementation of DialogPage supports properties that have appropriate converters or that are structures or arrays that can be expanded into properties that have appropriate converters. For a list of converters, see the System.ComponentModel namespace. The Visual Studio Extensibility Samples manages int, string, and System.Drawing.Size properties.
In my understanding I'm using valid components from the System.ComponentModel
namespace.
So what am I doing wrong? Do I have to treat arrays somehow differently?
List<string>
you have to provide a class which has an empty constructor, whichstring
does not. But I even tried to useList<MyCustomClass>
whereMyCustomClass
is a wrapperclass forstring
- but stil the values won't persist. – JeaninejeanlouisStringCollection
? – EstaminetStringCollection
and it doesn't get persisted :( – Cons