C# 使用JSON.NET模式分析JSON模式时抛出错误System.MethodAccessException

C# 使用JSON.NET模式分析JSON模式时抛出错误System.MethodAccessException,c#,json,json.net,jsonschema,C#,Json,Json.net,Jsonschema,我正在尝试JSON模式验证。我正在使用上的模式的基本示例。我有个例外 System.MethodAccessException: Attempt by method 'Newtonsoft.Json.Schema.JSchema.Parse(System.String)' to access method 'Newtonsoft.Json.Utilities.ValidationUtils.ArgumentNotNull(System.Object, System.String)' failed

我正在尝试JSON模式验证。我正在使用上的模式的基本示例。我有个例外

System.MethodAccessException: Attempt by method
'Newtonsoft.Json.Schema.JSchema.Parse(System.String)' to access method
'Newtonsoft.Json.Utilities.ValidationUtils.ArgumentNotNull(System.Object, System.String)' failed
我的代码在下面

[TestMethod]
    public void prettySimple()
    {
      string schemaJson = @"{
             'type': 'object',
             'properties': {
             'name': {'type':'string'},
             'hobbies': {
             'type': 'array',
             'items': {'type':'string'}
                }
               }
              }";

      JSchema schema = JSchema.Parse(schemaJson);
    }

听起来像是Newtonsoft.Json和Newtonsoft.Json.Schema之间的包不匹配

Newtonsoft.Json.Schema依赖于Newtonsoft.Json版本>=6.0.8。因此,请确保它在您的项目中是最新的

我首先安装了Newtonsoft.Json,然后模式包和代码运行良好

我的包配置:

 <packages>   
    <package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" />   
    <package id="Newtonsoft.Json.Schema" version="1.0.8" targetFramework="net45"/> 
</packages>


您是否引用了
Newtonsoft.Json.Schema
?是的。还引用了Newtonsoft.Json.Schema