我正在尝试用静态
   
    System.Version
   
   字段:
  
  [JsonObject(MemberSerialization.OptIn)]
public class MyObj
{
    [JsonProperty]
    private static string testStr;
    [JsonProperty(ItemConverterType = typeof(VersionConverter))]
    private static Version ver = System.Reflection.Assembly...Version;
    // some other non-serialized fields
    // ...
}
  
   我从中吸取了教训
   
    this question
   
   那个
   
    Version
   
   需要一个自定义转换器,我添加为
   
    ItemConverterType
   
   .然而,当我尝试像这样序列化它时,它失败了,错误如下:
   
    预期版本对象值
   
   :
  
  var o = MyObj();
using (StreamWriter file = File.CreateText(filename))
{
    JsonSerializer serializer = new JsonSerializer { Formatting = Formatting.Indented };
    serializer.Serialize(file, o); // error
}    
  
   如果我像这样修改字段的属性,效果很好:
  
  public class MyObj
{
    ...
    [JsonProperty]
    [JsonConverter(typeof(VersionConverter))]
    private static Version ver = System.Reflection.Assembly...Version;
    ...
  
   我对属性不熟悉。你能解释一下第一个失败的原因吗?我很确定我没有使用
   
    Json.NET
   
   没错,但我不知道为什么。