0

I have an option class looking like this:

public class FooOptions
{
    [Description("string"), DefaultValue("foo")]
    public string Foo { get; set; }

    [Description("Array of strings"), DefaultValue(new[] { "foo" })]
    public string[] FooArray { get; set; }   

    //...
}

I modify it through a PropertyGrid (System.Windows.Forms.PropertyGrid).

Everything used to work fine until I switched from .NET Framework to .NET Core 3.0.

When I click on the FooArray option in the PropertyGrid, the String Collection Editor window pops up as before: enter image description here

but when I try to add a new value, I get the following error "Constructor on type 'System.String' not found".

I tried to specify an editor via the component model (as advised by many articles):

[Editor("System.Windows.Forms.Design.StringCollectionEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor")]
public string[] FooArray { get; set; }

but it didn't work.

  • 1
    What GUI framework are you using? [`System.Windows.Forms.PropertyGrid`](https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.propertygrid?view=netcore-3.1)? Something else from [here](https://stackoverflow.com/q/8844947) or elsewhere? – dbc Mar 24 '20 at 20:02
  • The full exception stack trace, please. – Ian Kemp Mar 24 '20 at 21:31
  • 1
    StringCollectionEditor doesn't exist in .NET Core 3.0, you need .NET Core 3.1: https://github.com/dotnet/winforms/pull/1284 upgrade your project's target to .NET Core 3.1 and it will behave just like in .NET framework. – Simon Mourier Mar 25 '20 at 06:47
  • I applied @Simon solution and it works fine. Thank you! (tell me if I need to answer the question and accept it or do anything to close it) – Julien Perrin Mar 26 '20 at 10:44
  • If you're happy, you can answer yourself and get some points – Simon Mourier Mar 26 '20 at 12:56

1 Answers1

0

StringCollectionEditor doesn't exist in .NET Core 3.0. I upgraded my project's target to .NET Core 3.1 and it behaves like in .NET framework.