。NET Core 3.0“找不到System.String构造函数错误”,尝试从propertyGrid修改字符串[]时

问题描述 投票:0回答:1

我有一个如下所示的选项类:

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

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

    //...
}

我通过PropertyGrid(System.Windows.Forms.PropertyGrid)对其进行了修改。

在我从.NET Framework切换到.NET Core 3.0之前,一切正常。

当我单击PropertyGrid中的FooArray选项时,像以前一样弹出“字符串集合编辑器”窗口:enter image description here

但是当我尝试添加新值时,出现以下错误“找不到类型'System.String'的构造函数”。

我试图通过组件模型来指定编辑器(许多文章都建议这样做:]

[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; }

但是没用。

c# forms propertygrid asp.net-core-3.0
1个回答
0
投票

StringCollectionEditor在.NET Core 3.0中不存在。我将项目目标升级到.NET Core 3.1,其行为类似于.NET Framework。

© www.soinside.com 2019 - 2024. All rights reserved.