question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Azure Search .NET SDK throws InvalidOperationException with SerializationBinder

See original GitHub issue

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)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:34 (18 by maintainers)

github_iconTop GitHub Comments

3reactions
brjohnstmsftcommented, Feb 13, 2018

@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?

2reactions
stpriyankacommented, Feb 27, 2018

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Azure Search .Net SDK throws InvalidOperationException ...
This was caused by a known compatibility issue that many Azure SDKs have with JSON.NET version 10. The details are here and here....
Read more >
Azure Search .NET SDK throws InvalidOperationException ...
Coding example for the question Azure Search .NET SDK throws InvalidOperationException SerializationBinder with Newtonsoft.Json version higher than 9.0.1.
Read more >
Use Azure.Search.Documents (v11) in .NET
Learn how to create and manage search objects in a .NET application using C# and the Azure.Search.Documents (v11) client library.
Read more >
Untitled
... Added SerializationBinder properties to ... ISerializationBinder Interface - Newtonsoft Azure Search .NET SDK throws InvalidOperationException with .
Read more >
Azure Cognitive Search client library for .NET
Azure Cognitive Search APIs simplify query construction, faceted navigation, filters (including geo-spatial search), synonym mapping, typeahead queries, and ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found