【发布时间】:2017-11-19 18:25:05
【问题描述】:
我有课
class PartitionTemplate
{
public PartitionTemplate()
{
keepLabels = new List<string>();
partitions = new List<partition>();
}
[JsonProperty("keepLabels")]
public List<String> keepLabels { get; set; }
[JsonProperty("slot")]
public int slot { get; set; }
....
}
我的目标是用 propertyGrid 编辑它,使用以下代码:
PartitionTemplate partiTemplate;
//fi is FileInfo with the class as json using
//Newtonsoft.Json.JsonConvert.DeserializeObject<PartitionTemplate>(File.ReadAllText(partitionfile.FullName));
PartitionTemplate.ReadOrCreatePartitonConfigurationFile(out partiTemplate, fi);
propertyGrid1.SelectedObject = partiTemplate;
我的问题是:
当我尝试将add 元素转换为keepLabels 时,出现以下错误:
Exception thrown: 'System.MissingMethodException' in mscorlib.dll
Additional information: Constructor on type 'System.String' not found.
如何解决?
【问题讨论】:
标签: c# winforms json.net propertygrid