Search code examples
c#formspropertygridasp.net-core-3.0

.NET Core 3.0 "System.String constructor not found error" When Trying to modify a string[] from a propertyGrid


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.


Solution

  • 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.