azure-sdk-for-net: Azure Search .NET SDK throws InvalidOperationException with SerializationBinder

An exception thrown when entering operations with index (Exists, Create, Delete…). Encountered with .NET Core SDK 1.0.4 on Mac OSX 10.12.4

Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> 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 ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Search.IndexesOperationsExtensions.Exists(IIndexesOperations operations, String indexName, SearchRequestOptions searchRequestOptions)

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 34 (18 by maintainers)

Most upvoted comments

@isaacabraham Good point.

FYI @shahabhijeet @markcowl We found an incompatibility between JSON.NET 11 beta and Microsoft.Azure.Search. Specifically, the JsonSerializerSettings.Binder property, which Microsoft.Azure.Search currently references, has been deleted (it was marked as deprecated in JSON.NET 10). I don’t know if this change will affect ClientRuntime or not, but I thought I should give you folks a heads up. Do you see any harm in setting the max version of Newtonsoft.Json to 10 in AzSdk.reference.props?

I had same issue with .Net core. It solved just after degrading newtonsoft.Json to version 10.2. I guess with any of 10 versions it should work

It took longer than I thought, but we finally shipped a new SDK version with a hopefully comprehensive fix for the JSON.NET compatibility issues. It’s now available on NuGet. Closing this issue, hopefully for the last time. Thanks for your patience.

@isaacabraham I agree this is a terrible state of affairs. @shahabhijeet and I are having an offline discussion about possible solutions.