I have two projects in one solution, Project 1 and Project 2.
Project 1. Target Framework is .NET Core 2.1. It's an MVC project with controllers and views. It has a reference to Project 2. Nuget packages include:
- Microsoft.AspNetCore.App
- Microsoft.NETCore.App
Project 2. Target Framework is .NET Framework 4.6.1. It is a class library that gets data using NEST/ElasticSearch. I'm on a time crunch so I'm basically copying over this project from a .NET Framework 4.5.1 project that runs just fine. Nuget packages include:
NEST 1.7.1
ElasticSearch.Net 1.7.1
Newtonsoft.Json 7.0.1
Microsoft.AspNet.WebApi.Client 5.2.3
Error in Project 2:
I am not sure why I am getting this error if I am using the exact same code as the old 4.5.1 project. The only real difference is it is in the same solution as a .NET Core 2.1 project now.
Things I've considered:
- I tried upgrading the old project from .NET Framework 4.5.1 to .NET Framework 4.6.1. and it still runs fine, so I don't think it has to do with that.
- My hunch is that the ASP.NET Core project uses Newtonsoft.Json 10/11, while the .NET Framework 4.6.1 project uses Newtonsoft.Json 7.0.1 and that is somehow causing the problem. But if this is the case, what is the solution? Upgrading Project 2 to Newtonsoft.Json 10/11 also requires you to update NEST and ElasticSearch.Net which introduce a ton of breaking changes. Ideally I wouldn't have to touch the code in Project 2 very much. I would really like to get this to work but keep Project 1 in ASP.NET Core 2.1 and not have both projects in the old .NET Framework.

DefaultContractResolverhad a parameterized constructor taking aboolargument. It was marked as obsolete but did exist. But in Commit 1914b91 on Jan 28, 2017 that constructor was removed. It's clear that, for some reason, your Project 2 is expecting the constructor to still exist. - dbcElasticContractResolverwas using the parameterized constructor, or the call to the default constructor was optimized into a call to the parameterized constructor (since the default constructor did in fact call the parameterized) when Project 2 was built. - dbc