Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Azure .NET SDK with NewtonSoft.Json 9.0.2-beta results in SerializationBinder error #2552

Closed
fuocor opened this issue Nov 17, 2016 · 49 comments

Comments

@fuocor
Copy link

fuocor commented Nov 17, 2016

I am getting a TargetInvocationException on an index with the innerExcpetion of "Cannot get SerializationBinder because an ISerializationBinder was previously set." from Newtonsoft.Json.

The code is pretty straight forward:

        try
        {
            if(await SearchClient.Indexes.ExistsAsync(INDEX))
            {
                Logger.LogInformation("{0}", "Deleting index..\n");
                await SearchClient.Indexes.DeleteAsync(INDEX);
            }
            if(await SearchClient.DataSources.ExistsAsync(DATA_SOUCE))
            {
                Logger.LogInformation("{0}", "Deleting data source...\n");
                await SearchClient.DataSources.DeleteAsync(DATA_SOUCE);
            }
            if(await SearchClient.Indexers.ExistsAsync(INDEXER))
            {
                Logger.LogInformation("{0}", "Deleting indexer...\n");
                await SearchClient.Indexers.DeleteAsync(INDEXER);
            }
        }
        catch (Exception ex)
        {
            Logger.LogError("Error deleting indexing resources: {0}\r\n", ex.Message);
            throw;
        }

Any help is appreciated

rich

PS - I'm using Windows.Azure.Search (2.0.6-preview)

@fuocor
Copy link
Author

fuocor commented Nov 17, 2016

It appears that downgrading Newtonsoft.Json to 9.0.1 from 9.0.2-beta resolves the issue

@brjohnstmsft
Copy link
Member

@fuocor We're aware of this issue. It seems like a compatibility issue with the latest beta of JSON.NET, but we haven't been able to track it down yet.

@brjohnstmsft brjohnstmsft changed the title Indexes.ExistsAsync faulting Search SDK: Indexes.ExistsAsync faulting Nov 17, 2016
@brjohnstmsft brjohnstmsft self-assigned this Nov 17, 2016
@fuocor
Copy link
Author

fuocor commented Nov 17, 2016

thanks

@brjohnstmsft
Copy link
Member

brjohnstmsft commented Nov 17, 2016

@fuocor I'm having trouble getting a minimal repro of this problem. Would you be willing to share your code, or whatever minimal subset of it triggers the issue? Just calling ExistsAsync in a console app doesn't seem to be enough.

@laultman
Copy link

laultman commented Nov 20, 2016

I am getting the same error. Following this example:
https://docs.microsoft.com/en-us/azure/virtual-machines/virtual-machines-windows-csharp?toc=%2fazure%2fvirtual-machines%2fwindows%2ftoc.json
Console app .NET Core 1.1.0
My project.json file content:
{
"version": "1.0.0-*",
"buildOptions": {
"emitEntryPoint": true
},

"dependencies": {
"Microsoft.Azure.Management.ResourceManager": "1.4.0-preview",
"Microsoft.IdentityModel.Clients.ActiveDirectory": "3.13.6",
"Microsoft.Rest.ClientRuntime.Azure": "3.3.3",
"Newtonsoft.Json": "9.0.2-beta1",
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.1.0"
},
"Microsoft.Azure.Management.Storage": "5.0.2-preview",
"Microsoft.Azure.Management.Network": "8.0.0-preview",
"Microsoft.Azure.Management.Compute": "13.1.0-prerelease"
},
"runtimes": {
"win10-x64": {}
},
"frameworks": {
"netcoreapp1.0": {
"imports": [
"dnxcore50",
"portable-net45+win8"
]
}
}
}

@fuocor
Copy link
Author

fuocor commented Nov 21, 2016

Just downgrade to 9.1 of NewtonSoft to work around it
Rich

Sent from my Windows 10 phone

From: Larry Aultmanmailto:notifications@github.com
Sent: Sunday, November 20, 2016 6:14 PM
To: Azure/azure-sdk-for-netmailto:azure-sdk-for-net@noreply.github.com
Cc: Richard Fuocomailto:richf@whact.com; Mentionmailto:mention@noreply.github.com
Subject: Re: [Azure/azure-sdk-for-net] Search SDK: Indexes.ExistsAsync faulting (#2552)

I am getting the same error. Following this example:
https://docs.microsoft.com/en-us/azure/virtual-machines/virtual-machines-windows-csharp-template?toc=%2fazure%2fvirtual-machines%2fwindows%2ftoc.json
Console app .NET Core 1.1.0
My project.json file content:
{
"version": "1.0.0-*",
"buildOptions": {
"emitEntryPoint": true
},

"dependencies": {
"Microsoft.Azure.Management.ResourceManager": "1.4.0-preview",
"Microsoft.IdentityModel.Clients.ActiveDirectory": "3.13.6",
"Microsoft.Rest.ClientRuntime.Azure": "3.3.3",
"Newtonsoft.Json": "9.0.2-beta1",
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.1.0"
},
"Microsoft.Azure.Management.Storage": "5.0.2-preview",
"Microsoft.Azure.Management.Network": "8.0.0-preview",
"Microsoft.Azure.Management.Compute": "13.1.0-prerelease"
},
"runtimes": {
"win10-x64": {}
},
"frameworks": {
"netcoreapp1.0": {
"imports": [
"dnxcore50",
"portable-net45+win8"
]
}
}
}

You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHubhttps://github.com//issues/2552#issuecomment-261813909, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AO7kwRGkFBq18Uqfy1VU5SR2QapUuqUKks5rANRLgaJpZM4K0sJB.

@brjohnstmsft
Copy link
Member

Thanks @laultman. This confirms that it is a more general issue not specific to the Azure Search SDK. I'll update the title of this issue accordingly and try to get the right people looking into it.

In the meantime, the workaround is to downgrade as @fuocor suggested.

@brjohnstmsft brjohnstmsft changed the title Search SDK: Indexes.ExistsAsync faulting Using Azure .NET SDK with NewtonSoft.Json 9.0.2-beta results in SerializationBinder error Nov 22, 2016
@brjohnstmsft brjohnstmsft removed their assignment Nov 22, 2016
@brjohnstmsft
Copy link
Member

FYI @hovsepm @markcowl

@markcowl
Copy link
Member

markcowl commented Dec 2, 2016

Description

Get a minimal repro of the issue and determine the root cause. File issues for fix.

Cost: 2

@efeurich
Copy link

efeurich commented Feb 8, 2017

Thanks guys you save me a lot of time.

@bottomup
Copy link

Same here. The problem occurred when I added 2 fields to an index. I was on NewtonSoft.Json 10, a downgrade to 9 made it work again.

Probably it works when updating to NewtonSoft.Json 10 if the index is untouched. Changing the index causes the problem.

@brjohnstmsft
Copy link
Member

@bottomup Note that this issue covers all Azure .NET libraries. It sounds like you're talking about the Azure Search library in particular -- is that correct? If so, which version are you using?

@bottomup
Copy link

@brjohnstmsft correct. I'm using Microsoft.Azure.Search 3.0.3.
However, I'm also using other Microsoft.Azure packages, but didn't experience these issues there.

@brjohnstmsft
Copy link
Member

@bottomup Can you try upgrading to 3.0.4 and let me know if you still experience the problem?

@jbreuer
Copy link

jbreuer commented May 24, 2017

I'm having the same issue with Azure Search. Upgraded to 3.0.4 and I get the error "Cannot get SerializationBinder because an ISerializationBinder was previously set.". Using Newtonsoft.Json version 10.0.2.

@galvesribeiro
Copy link

Its important to note that this is not a particular nuget issue... Any nuget from Azure SDK that is using 9.0.1 and you try to use 10.x.x+, you will get that problem...

@jbreuer
Copy link

jbreuer commented May 24, 2017

Thanks for the info. So do we need to wait until a new version comes out that uses 10.x.x+ ? I can't downgrade to 9.

@galvesribeiro
Copy link

Yeah, unfortunately... I did rollback to 9+ for a particular project that use those packages in order to be unblocked...

@jbreuer
Copy link

jbreuer commented May 26, 2017

I tried adding the following binding redirect, but it didn't work:

<dependentAssembly>
  <assemblyIdentity name="Microsoft.Rest.ClientRuntime.Azure" publicKeyToken="31bf3856ad364e35" />
  <bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>

@markcowl Any idea when a new version will be released which supports NewtonSoft.Json v10?

@bottomup
Copy link

@brjohnstmsft I tried your suggestion and upgraded to 3.0.4, but the same issue arises. Downgraded again to NewtonSoft.Json 9.0.1

@brjohnstmsft
Copy link
Member

@bottomup Thanks for confirming. I wasn't sure if the issue with the Azure Search SDK is related to the issue affecting all Azure .NET SDKs, but it looks like it is related. @markcowl is working on a fix.

@isaacabraham
Copy link

Just adding to this - I see this, but only when I generate an invalid search query in the Azure Search SDK - then it comes back with this error (rather than the "real" error).

@hovsepm
Copy link
Contributor

hovsepm commented May 31, 2017

This is an issue in ClientRuntime.Azure and will be fixed shortly.

@brjohnstmsft
Copy link
Member

@hovsepm Thanks Hovsep. The Azure Search SDK does some custom JSON serialization stuff as well, so once the issue in ClientRuntime.Azure is fixed, I still have to verify whether more work needs to be done to fix the issue in Microsoft.Azure.Search.

@galvesribeiro
Copy link

@hovsepm: Will #3304 solve the other nugets (like compute, networking, etc...) as well? As I mentioned, it is a general issue...

@markcowl
Copy link
Member

markcowl commented May 31, 2017

We misunderstood the root cause for this, which is why we had the additional delay. Hovsep's fix will allow those using NetCore and those using binding redirects in net452 to use Newtonsoft.Json. Those who cannot use binding redirects will need us to republish the individual management libraries, which will happen next month.

@brjohnstmsft Code the depends on ClientRuntime exception handling should be fixed automatically with an upgrade. Code that directly uses properties deprecated in Version 10 will have to be updated.

@markcowl
Copy link
Member

@galvesribeiro Those libraries are compatible with the new runtime, so you should be able to upgrade. Note that you will need to be using NetCore or assembly binding redirects to take this fix, because the assembly identity for Newtonsoft.Json has changed.

@galvesribeiro
Copy link

@markcowl thankfuly I'm free from binding redirect hell by using .Net Core :)

Thanks! Looking forward for the update.

@hovsepm
Copy link
Contributor

hovsepm commented Jun 2, 2017

The issue is resolved. Please use Microsoft.Rest.ClientRuntime.Azure v 3.3.8 or later.

@hovsepm hovsepm closed this as completed Jun 2, 2017
@brjohnstmsft
Copy link
Member

@hovsepm @markcowl Not sure this should be closed until the libraries depending on Microsoft.Rest.ClientRuntime.Azure have been republished, unless there is another issue tracking this work...? I'd love to republish the Search libraries, but I see that AzSdk.reference.props in the vs17Dev branch hasn't been updated with the new references to Microsoft.Rest.ClientRuntime.Azure and NewtonSoft.Json yet. What's the ETA for this?

@hovsepm
Copy link
Contributor

hovsepm commented Jun 6, 2017

@shahabhijeet should also have an idea when that could happen.
@brjohnstmsft you should not need to publish new library. Does Search has direct dependency on any version?

@brjohnstmsft
Copy link
Member

@hovsepm No, but the minimum required version is 3.3.6, not 3.3.8. A few of our customers have already reported running into this issue as soon as they upgrade to JSON.NET 10. Referencing 3.3.8 resolves it, but in the meantime it creates extra support traffic for us.

@shahabhijeet
Copy link
Member

@brjohnstmsft following [fix] (JamesNK/Newtonsoft.Json#1341) fixes underlying error. New set of Clientruntime libraries are on track to be republished by next week.
In the mean time, upgrading to newtonsoft.json 10.0.3 will fix the issue whoever wants to upgrade to newtonsoft 10+

@brjohnstmsft
Copy link
Member

@shahabhijeet Awesome, thanks for the update!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests