未找到 String 的构造函数

Constructor not found for String

如果我在 属性 网格中有一个对象包含 List<string[]>Dictionary<string,string[]>(使用 GenericDictionaryEditor),当我单击 [= 旁边的详细信息时20=] 然后点击添加,弹出一条消息说找不到构造函数(对于列表)或者没有找到无参数构造函数(对于字典)。我真的不了解编辑器或 属性 网格,如有任何帮助,我们将不胜感激。

[DataMember(Name="FolderPaths")]
[ReadOnly(false)]
[Description("List of folder paths")]
[Editor(typeof(Wexman.Design.GenericDictionaryEditor<string, string[]>), typeof(UITypeEditor))]
[Wexman.Design.GenericDictionaryEditor(Title="Folder Paths")]
public Dictionary<string, string[]> FolderPaths { get; set; }

这个说找不到 System.string[].

的构造函数
[DataMember(Name="FolderPaths")]
[ReadOnly(false)]
[Description("List of folder paths")]
public List<string[]> FolderPaths { get; set; }

一个解决方案是为 string[] 类型注册一个 TypeDescriptionProvider。这是示例代码(您需要在程序开始时注册它,然后显示任何 属性 网格):

...
TypeDescriptor.AddProvider(new StringArrayDescriptionProvider(), typeof(string[]));
...

这里是 StringArrayDescriptionProvider 代码:

public class StringArrayDescriptionProvider : TypeDescriptionProvider
{
    private static TypeDescriptionProvider _baseProvider;

    static StringArrayDescriptionProvider()
    {
       // get default metadata
        _baseProvider = TypeDescriptor.GetProvider(typeof(string[]));
    }

    public override object CreateInstance(IServiceProvider provider, Type objectType, Type[] argTypes, object[] args)
    {
        // this is were we define create the instance
        // NB: .NET could do this IMHO...
        return Array.CreateInstance(typeof(string), 0);
    }

    public override IDictionary GetCache(object instance)
    {
        return _baseProvider.GetCache(instance);
    }

    public override ICustomTypeDescriptor GetExtendedTypeDescriptor(object instance)
    {
        return _baseProvider.GetExtendedTypeDescriptor(instance);
    }

    public override string GetFullComponentName(object component)
    {
        return _baseProvider.GetFullComponentName(component);
    }

    public override Type GetReflectionType(Type objectType, object instance)
    {
        return _baseProvider.GetReflectionType(objectType, instance);
    }

    public override Type GetRuntimeType(Type reflectionType)
    {
        return _baseProvider.GetRuntimeType(reflectionType);
    }

    public override ICustomTypeDescriptor GetTypeDescriptor(Type objectType, object instance)
    {
        return _baseProvider.GetTypeDescriptor(objectType, instance);
    }

    public override bool IsSupportedType(Type type)
    {
        return _baseProvider.IsSupportedType(type);
    }
}

这是它的样子: