0

我在 .NET Core 上使用 Azure Search .NET SDK(特别是从 Github 克隆示例 - https://github.com/Azure-Samples/search-dotnet-getting-started

当使用索引(创建,删除...)输入任何操作时,它会从 Newtonsoft.Json 中使用 SerializationBinder 引发异常,如下所示

System.InvalidOperationException: Cannot get SerializationBinder because an ISerializationBinder was previously set.    at Newtonsoft.Json.JsonSerializer.get_Binder()    
--- End of inner exception stack trace ---    
    at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)    
    at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)    
    at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)   
    at Microsoft.Rest.Azure.JsonSerializerExtensions.WithoutConverter(JsonSerializer serializer, JsonConverter converterToExclude)    
    at Microsoft.Rest.Azure.CloudErrorJsonConverter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)    
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)   
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)    
    at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)    
    at Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject[T](String json, JsonSerializerSettings settings)    at Microsoft.Azure.Search.IndexesOperations.<GetWithHttpMessagesAsync>d__12.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---    
        at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)    at Microsoft.Azure.Search.ExistsHelper.<ExistsFromGetResponse>d__0`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)    at Microsoft.Azure.Search.IndexesOperationsExtensions.<ExistsAsync>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown --

当我克隆公共 github 存储库时,我相信 SDK 本身有问题。那正确吗?

4

2 回答 2

1

This was caused by a known compatibility issue that many Azure SDKs have with JSON.NET version 10. The details are here and here.

This was fixed in Microsoft.Azure.Search versions 3.0.5 and 4.0.2-preview.

于 2017-07-03T20:39:00.167 回答
0

如果索引不存在,我也可以重现您在尝试执行DeleteHotelsIndexIfExists函数时提到的问题。其他操作,例如创建索引上传文档在我这边工作正常。

经过一番调查,我发现Microsoft.Extensions.Configuration.Json是预览版。

请尝试更新到最新的稳定 1.1.2 版本。然后它在我这边正常工作。

在此处输入图像描述

在此处输入图像描述

于 2017-07-03T05:26:03.817 回答