I'm using `netstandard2.1` library in my `netcoreapp3.0` web application. When adding my service in `Startup`, I'm getting the below error:

> 
> 'Could not load type 'Microsoft.AspNetCore.Mvc.MvcJsonOptions' from
>  assembly 'Microsoft.AspNetCore.Mvc.Formatters.Json, Version=3.0.0.0
> 
> 
> 

I'm also using some features from `Microsoft.AspNetCore.Mvc` 2.2.0 package in my class library.

Here is my library `.csproj`,

```xml
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netstandard2.1</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
  </ItemGroup>

</Project>

```

Here is my `ServiceExtensions` class from my library,

```cs
public static class ServiceExtensions
{
    public static IMvcBuilder AddMyLibrary(this IMvcBuilder builder)
    {
        builder.Services.TryAddSingleton<IHttpContextAccessor, HttpContextAccessor>();
        builder.AddJsonOptions(options =>
        {
            options.SerializerSettings.ContractResolver = new DefaultContractResolver();
        });
        builder.Services.ConfigureOptions<ConfigureLibraryOptions>();

        return builder;
    }
}

```

Here is my `ConfigureLibraryOptions` class,

```cs
public class ConfigureLibraryOptions : IConfigureOptions<MvcOptions>
{
    public void Configure(MvcOptions options)
    {
        options.ModelBinderProviders.Insert(0, new CustomBinderProvider());
    }
}

```

Here is the `ConfigureServices` from `Startup`,

```cs
services.AddControllersWithViews().AddMyLibrary();

```

Please help on why I'm getting this error and assist on how to solve this?
['https://Stackoverflow.com/questions/58362757', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/10851213/']
The problem is most likely with the incompatible nuget packages for .net core 3.1 above. Take a look at your packages and eventually upgrade to compatible version of core 3.1. That should really fix the issue I had one with Automapper and others had with Swagger.

If you are using AutoMapper you should upgrade to 7.0.0

See <https://medium.com/@nicky2983/how-to-using-automapper-on-asp-net-core-3-0-via-dependencyinjection-a5d25bd33e5b>
In my case, the solution was to add `services.AddControllers()` as described under <https://github.com/RicoSuter/NSwag/issues/1961#issuecomment-515631411>.