.NET Core 3.0 "System.String constructor not found error" 尝试从 propertyGrid 修改字符串 [] 时
.NET Core 3.0 "System.String constructor not found error" When Trying to modify a string[] from a propertyGrid
我有一个选项 class 看起来像这样:
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 选项时,字符串集合编辑器 window 像以前一样弹出:
但是当我尝试添加新值时,出现以下错误 "Constructor on type 'System.String' not found"。
我尝试通过组件模型指定一个编辑器(许多文章建议):
[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; }
但是没用。
.NET Core 3.0 中不存在 StringCollectionEditor。
我将项目的目标升级到 .NET Core 3.1,它的行为就像在 .NET 框架中一样。
我有一个选项 class 看起来像这样:
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 选项时,字符串集合编辑器 window 像以前一样弹出:
但是当我尝试添加新值时,出现以下错误 "Constructor on type 'System.String' not found"。
我尝试通过组件模型指定一个编辑器(许多文章建议):
[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; }
但是没用。
.NET Core 3.0 中不存在 StringCollectionEditor。 我将项目的目标升级到 .NET Core 3.1,它的行为就像在 .NET 框架中一样。